本文整理汇总了C++中BS_EXCEPT函数的典型用法代码示例。如果您正苦于以下问题:C++ BS_EXCEPT函数的具体用法?C++ BS_EXCEPT怎么用?C++ BS_EXCEPT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BS_EXCEPT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BS_EXCEPT
void RTTITypeBase::addNewField(RTTIField* field)
{
if(field == nullptr)
{
BS_EXCEPT(InvalidParametersException,
"Field argument can't be null.");
}
int uniqueId = field->mUniqueId;
auto foundElementById = std::find_if(mFields.begin(), mFields.end(), [uniqueId](RTTIField* x) { return x->mUniqueId == uniqueId; });
if(foundElementById != mFields.end())
{
BS_EXCEPT(InternalErrorException,
"Field with the same ID already exists.");
}
String& name = field->mName;
auto foundElementByName = std::find_if(mFields.begin(), mFields.end(), [&name](RTTIField* x) { return x->mName == name; });
if(foundElementByName != mFields.end())
{
BS_EXCEPT(InternalErrorException,
"Field with the same name already exists.");
}
mFields.push_back(field);
}
示例2: BS_EXCEPT
void D3D9TimerQuery::createQuery()
{
mDevice = D3D9RenderAPI::getActiveD3D9Device();
HRESULT hr = mDevice->CreateQuery(D3DQUERYTYPE_TIMESTAMPDISJOINT, &mDisjointQuery);
if (hr != S_OK)
{
BS_EXCEPT(RenderingAPIException, "Failed to create a timer query.");
}
hr = mDevice->CreateQuery(D3DQUERYTYPE_TIMESTAMPFREQ, &mFreqQuery);
if (hr != S_OK)
{
BS_EXCEPT(RenderingAPIException, "Failed to create a timer query.");
}
hr = mDevice->CreateQuery(D3DQUERYTYPE_TIMESTAMP, &mBeginQuery);
if (hr != S_OK)
{
BS_EXCEPT(RenderingAPIException, "Failed to create a timer query.");
}
hr = mDevice->CreateQuery(D3DQUERYTYPE_TIMESTAMP, &mEndQuery);
if (hr != S_OK)
{
BS_EXCEPT(RenderingAPIException, "Failed to create a timer query.");
}
}
示例3: BS_EXCEPT
void D3D11HardwareBuffer::copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset,
UINT32 dstOffset, UINT32 length, bool discardWholeBuffer)
{
// If we're copying same-size buffers in their entirety
if (srcOffset == 0 && dstOffset == 0 &&
length == mSizeInBytes && mSizeInBytes == srcBuffer.getSizeInBytes())
{
mDevice.getImmediateContext()->CopyResource(mD3DBuffer, static_cast<D3D11HardwareBuffer&>(srcBuffer).getD3DBuffer());
if (mDevice.hasError())
{
String errorDescription = mDevice.getErrorDescription();
BS_EXCEPT(RenderingAPIException, "Cannot copy D3D11 resource\nError Description:" + errorDescription);
}
}
else
{
// Copy subregion
D3D11_BOX srcBox;
srcBox.left = (UINT)srcOffset;
srcBox.right = (UINT)srcOffset + length;
srcBox.top = 0;
srcBox.bottom = 1;
srcBox.front = 0;
srcBox.back = 1;
mDevice.getImmediateContext()->CopySubresourceRegion(mD3DBuffer, 0, (UINT)dstOffset, 0, 0,
static_cast<D3D11HardwareBuffer&>(srcBuffer).getD3DBuffer(), 0, &srcBox);
if (mDevice.hasError())
{
String errorDescription = mDevice.getErrorDescription();
BS_EXCEPT(RenderingAPIException, "Cannot copy D3D11 subresource region\nError Description:" + errorDescription);
}
}
}
示例4: mContext
D3D11TimerQuery::D3D11TimerQuery()
:mFinalized(false), mContext(nullptr), mBeginQuery(nullptr),
mEndQuery(nullptr), mDisjointQuery(nullptr), mTimeDelta(0.0f), mQueryEndCalled(false)
{
D3D11RenderAPI* rs = static_cast<D3D11RenderAPI*>(RenderAPICore::instancePtr());
D3D11Device& device = rs->getPrimaryDevice();
D3D11_QUERY_DESC queryDesc;
queryDesc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT;
queryDesc.MiscFlags = 0;
HRESULT hr = device.getD3D11Device()->CreateQuery(&queryDesc, &mDisjointQuery);
if(hr != S_OK)
{
BS_EXCEPT(RenderingAPIException, "Failed to create a timer query.");
}
queryDesc.Query = D3D11_QUERY_TIMESTAMP;
hr = device.getD3D11Device()->CreateQuery(&queryDesc, &mBeginQuery);
if(hr != S_OK)
{
BS_EXCEPT(RenderingAPIException, "Failed to create a timer query.");
}
hr = device.getD3D11Device()->CreateQuery(&queryDesc, &mEndQuery);
if(hr != S_OK)
{
BS_EXCEPT(RenderingAPIException, "Failed to create a timer query.");
}
mContext = device.getImmediateContext();
BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_Query);
}
示例5: BS_EXCEPT
void* GLIndexBufferCore::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
{
GLenum access = 0;
if(mIsLocked)
{
BS_EXCEPT(InternalErrorException,
"Invalid attempt to lock an index buffer that has already been locked");
}
#if BS_PROFILING_ENABLED
if (options == GBL_READ_ONLY || options == GBL_READ_WRITE)
{
BS_INC_RENDER_STAT_CAT(ResRead, RenderStatObject_IndexBuffer);
}
if (options == GBL_READ_WRITE || options == GBL_WRITE_ONLY || options == GBL_WRITE_ONLY_DISCARD || options == GBL_WRITE_ONLY_NO_OVERWRITE)
{
BS_INC_RENDER_STAT_CAT(ResWrite, RenderStatObject_IndexBuffer);
}
#endif
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBufferId);
if ((options == GBL_WRITE_ONLY) || (options == GBL_WRITE_ONLY_NO_OVERWRITE) || (options == GBL_WRITE_ONLY_DISCARD))
{
access = GL_MAP_WRITE_BIT;
if(options == GBL_WRITE_ONLY_DISCARD)
access |= GL_MAP_INVALIDATE_BUFFER_BIT;
else if(options == GBL_WRITE_ONLY_NO_OVERWRITE)
access |= GL_MAP_UNSYNCHRONIZED_BIT;
}
else if (options == GBL_READ_ONLY)
access = GL_MAP_READ_BIT;
else
access = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
void* pBuffer = nullptr;
if (length > 0)
{
pBuffer = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length, access);
if (pBuffer == nullptr)
{
BS_EXCEPT(InternalErrorException, "Index Buffer: Out of memory");
}
mZeroLocked = false;
}
else
mZeroLocked = true;
void* retPtr = static_cast<void*>(static_cast<unsigned char*>(pBuffer));
mIsLocked = true;
return retPtr;
}
示例6: BS_EXCEPT
void RenderTextureCore::initialize()
{
RenderTargetCore::initialize();
const RENDER_SURFACE_CORE_DESC& colorSurface = mDesc.colorSurface;
if (colorSurface.texture != nullptr)
{
SPtr<TextureCore> texture = colorSurface.texture;
if (texture->getProperties().getUsage() != TU_RENDERTARGET)
BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
mColorSurface = TextureCore::requestView(texture, colorSurface.mipLevel, 1,
colorSurface.face, colorSurface.numFaces, GVU_RENDERTARGET);
}
const RENDER_SURFACE_CORE_DESC& depthStencilSurface = mDesc.depthStencilSurface;
if (depthStencilSurface.texture != nullptr)
{
SPtr<TextureCore> texture = depthStencilSurface.texture;
if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
mDepthStencilSurface = TextureCore::requestView(texture, depthStencilSurface.mipLevel, 1,
depthStencilSurface.face, 0, GVU_DEPTHSTENCIL);
}
throwIfBuffersDontMatch();
if (mColorSurface != nullptr)
{
assert(mColorSurface->getTexture() != nullptr);
SPtr<TextureCore> colorTexture = mColorSurface->getTexture();
const TextureProperties& texProps = colorTexture->getProperties();
UINT32 numSlices;
if (texProps.getTextureType() == TEX_TYPE_3D)
numSlices = texProps.getDepth();
else
numSlices = texProps.getNumFaces();
if ((mColorSurface->getFirstArraySlice() + mColorSurface->getNumArraySlices()) > numSlices)
{
BS_EXCEPT(InvalidParametersException, "Provided number of faces is out of range. Face: " +
toString(mColorSurface->getFirstArraySlice() + mColorSurface->getNumArraySlices()) +
". Max num faces: " + toString(numSlices));
}
if (mColorSurface->getMostDetailedMip() > texProps.getNumMipmaps())
{
BS_EXCEPT(InvalidParametersException, "Provided number of mip maps is out of range. Mip level: " +
toString(mColorSurface->getMostDetailedMip()) + ". Max num mipmaps: " + toString(texProps.getNumMipmaps()));
}
}
}
示例7: switch
void D3D11RenderAPI::bindGpuProgram(const SPtr<GpuProgramCore>& prg)
{
THROW_IF_NOT_CORE_THREAD;
switch(prg->getProperties().getType())
{
case GPT_VERTEX_PROGRAM:
{
D3D11GpuVertexProgramCore* d3d11GpuProgram = static_cast<D3D11GpuVertexProgramCore*>(prg.get());
mDevice->getImmediateContext()->VSSetShader(d3d11GpuProgram->getVertexShader(), nullptr, 0);
mActiveVertexShader = std::static_pointer_cast<D3D11GpuProgramCore>(prg);
break;
}
case GPT_FRAGMENT_PROGRAM:
{
D3D11GpuFragmentProgramCore* d3d11GpuProgram = static_cast<D3D11GpuFragmentProgramCore*>(prg.get());
mDevice->getImmediateContext()->PSSetShader(d3d11GpuProgram->getPixelShader(), nullptr, 0);
break;
}
case GPT_GEOMETRY_PROGRAM:
{
D3D11GpuGeometryProgramCore* d3d11GpuProgram = static_cast<D3D11GpuGeometryProgramCore*>(prg.get());
mDevice->getImmediateContext()->GSSetShader(d3d11GpuProgram->getGeometryShader(), nullptr, 0);
break;
}
case GPT_DOMAIN_PROGRAM:
{
D3D11GpuDomainProgramCore* d3d11GpuProgram = static_cast<D3D11GpuDomainProgramCore*>(prg.get());
mDevice->getImmediateContext()->DSSetShader(d3d11GpuProgram->getDomainShader(), nullptr, 0);
break;
}
case GPT_HULL_PROGRAM:
{
D3D11GpuHullProgramCore* d3d11GpuProgram = static_cast<D3D11GpuHullProgramCore*>(prg.get());
mDevice->getImmediateContext()->HSSetShader(d3d11GpuProgram->getHullShader(), nullptr, 0);
break;
}
case GPT_COMPUTE_PROGRAM:
{
D3D11GpuComputeProgramCore* d3d11GpuProgram = static_cast<D3D11GpuComputeProgramCore*>(prg.get());
mDevice->getImmediateContext()->CSSetShader(d3d11GpuProgram->getComputeShader(), nullptr, 0);
break;
}
default:
BS_EXCEPT(InvalidParametersException, "Unsupported gpu program type: " + toString(prg->getProperties().getType()));
}
if (mDevice->hasError())
BS_EXCEPT(RenderingAPIException, "Failed to bindGpuProgram : " + mDevice->getErrorDescription());
BS_INC_RENDER_STAT(NumGpuProgramBinds);
}
示例8: BS_EXCEPT
void GLTextureBuffer::blitFromTexture(GLTextureBuffer* src, const PixelVolume& srcBox, const PixelVolume& dstBox)
{
if (src->mMultisampleCount > 0 && mMultisampleCount == 0) // Resolving MS texture
{
if (mTarget != GL_TEXTURE_2D || mTarget != GL_TEXTURE_2D_MULTISAMPLE)
BS_EXCEPT(InvalidParametersException, "Non-2D multisampled texture not supported.");
GLint currentFBO = 0;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFBO);
GLuint readFBO = GLRTTManager::instance().getBlitReadFBO();
GLuint drawFBO = GLRTTManager::instance().getBlitDrawFBO();
// Attach source texture
glBindFramebuffer(GL_FRAMEBUFFER, readFBO);
src->bindToFramebuffer(0, 0, true);
// Attach destination texture
glBindFramebuffer(GL_FRAMEBUFFER, drawFBO);
bindToFramebuffer(0, 0, true);
// Perform blit
glBindFramebuffer(GL_READ_FRAMEBUFFER, readFBO);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFBO);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
glBlitFramebuffer(srcBox.left, srcBox.top, srcBox.right, srcBox.bottom,
dstBox.left, dstBox.top, dstBox.right, dstBox.bottom, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Restore the previously bound FBO
glBindFramebuffer(GL_FRAMEBUFFER, currentFBO);
}
else // Just plain copy
{
if (mMultisampleCount != src->mMultisampleCount)
BS_EXCEPT(InvalidParametersException, "When copying textures their multisample counts must match.");
if (mTarget == GL_TEXTURE_3D) // 3D textures can't have arrays so their Z coordinate is handled differently
{
glCopyImageSubData(src->mTextureID, src->mTarget, src->mLevel, srcBox.left, srcBox.top, srcBox.front,
mTextureID, mTarget, mLevel, dstBox.left, dstBox.top, dstBox.front, srcBox.getWidth(), srcBox.getHeight(), srcBox.getDepth());
}
else
{
glCopyImageSubData(src->mTextureID, src->mTarget, src->mLevel, srcBox.left, srcBox.top, src->mFace,
mTextureID, mTarget, mLevel, dstBox.left, dstBox.top, mFace, srcBox.getWidth(), srcBox.getHeight(), 1);
}
}
}
示例9: BS_EXCEPT
void RTTIField::checkIsArray(bool array)
{
if(array && !mIsVectorType)
{
BS_EXCEPT(InternalErrorException,
"Invalid field type. Needed an array type but got a single type.");
}
if(!array && mIsVectorType)
{
BS_EXCEPT(InternalErrorException,
"Invalid field type. Needed a single type but got an array type.");
}
}
示例10: BS_EXCEPT
void D3D11RenderAPI::setVertexBuffers(UINT32 index, SPtr<VertexBufferCore>* buffers, UINT32 numBuffers)
{
THROW_IF_NOT_CORE_THREAD;
UINT32 maxBoundVertexBuffers = mCurrentCapabilities->getMaxBoundVertexBuffers();
if(index < 0 || (index + numBuffers) >= maxBoundVertexBuffers)
BS_EXCEPT(InvalidParametersException, "Invalid vertex index: " + toString(index) + ". Valid range is 0 .. " + toString(maxBoundVertexBuffers - 1));
ID3D11Buffer* dx11buffers[MAX_BOUND_VERTEX_BUFFERS];
UINT32 strides[MAX_BOUND_VERTEX_BUFFERS];
UINT32 offsets[MAX_BOUND_VERTEX_BUFFERS];
for(UINT32 i = 0; i < numBuffers; i++)
{
SPtr<D3D11VertexBufferCore> vertexBuffer = std::static_pointer_cast<D3D11VertexBufferCore>(buffers[i]);
const VertexBufferProperties& vbProps = vertexBuffer->getProperties();
dx11buffers[i] = vertexBuffer->getD3DVertexBuffer();
strides[i] = vbProps.getVertexSize();
offsets[i] = 0;
}
mDevice->getImmediateContext()->IASetVertexBuffers(index, numBuffers, dx11buffers, strides, offsets);
BS_INC_RENDER_STAT(NumVertexBufferBinds);
}
示例11: T
T TGpuDataParam<T, Core>::get(UINT32 arrayIdx) const
{
if (mParent == nullptr)
return T();
GpuParamBufferType paramBlock = mParent->getParamBlockBuffer(mParamDesc->paramBlockSet, mParamDesc->paramBlockSlot);
if (paramBlock == nullptr)
return T();
#if BS_DEBUG_MODE
if (arrayIdx >= mParamDesc->arraySize)
{
BS_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " +
toString(mParamDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
}
#endif
UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T));
T value;
paramBlock->read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
return value;
}
示例12: sizeof
void TGpuParamStruct<Core>::get(void* value, UINT32 sizeBytes, UINT32 arrayIdx) const
{
if (mParent == nullptr)
return;
GpuParamBufferType paramBlock = mParent->getParamBlockBuffer(mParamDesc->paramBlockSet, mParamDesc->paramBlockSlot);
if (paramBlock == nullptr)
return;
UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
#if BS_DEBUG_MODE
if (sizeBytes > elementSizeBytes)
{
LOGWRN("Provided element size larger than maximum element size. Maximum size: " +
toString(elementSizeBytes) + ". Supplied size: " + toString(sizeBytes));
}
if (arrayIdx >= mParamDesc->arraySize)
{
BS_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " +
toString(mParamDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
}
#endif
sizeBytes = std::min(elementSizeBytes, sizeBytes);
paramBlock->read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), value, sizeBytes);
}
示例13: BS_EXCEPT
ScriptObjectBase::~ScriptObjectBase()
{
if(mManagedInstance != nullptr)
BS_EXCEPT(InvalidStateException, "Script object is being destroyed without its instance previously being released.");
ScriptObjectManager::instance().unregisterScriptObject(this);
}
示例14: toString
void RenderTextureCore::throwIfBuffersDontMatch() const
{
if (mColorSurface == nullptr || mDepthStencilSurface == nullptr)
return;
const TextureProperties& colorProps = mColorSurface->getTexture()->getProperties();
const TextureProperties& depthProps = mDepthStencilSurface->getTexture()->getProperties();
UINT32 colorMsCount = colorProps.getMultisampleCount();
UINT32 depthMsCount = depthProps.getMultisampleCount();
if (colorMsCount == 0)
colorMsCount = 1;
if (depthMsCount == 0)
depthMsCount = 1;
if (colorProps.getWidth() != depthProps.getWidth() ||
colorProps.getHeight() != depthProps.getHeight() ||
colorMsCount != depthMsCount)
{
String errorInfo = "\nWidth: " + toString(colorProps.getWidth()) + "/" + toString(depthProps.getWidth());
errorInfo += "\nHeight: " + toString(colorProps.getHeight()) + "/" + toString(depthProps.getHeight());
errorInfo += "\nMultisample Count: " + toString(colorMsCount) + "/" + toString(depthMsCount);
BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
}
}
示例15: ZeroMemory
void D3D11BlendState::createInternal()
{
D3D11_BLEND_DESC blendStateDesc;
ZeroMemory(&blendStateDesc, sizeof(D3D11_BLEND_DESC));
blendStateDesc.AlphaToCoverageEnable = mProperties.getAlphaToCoverageEnabled();
blendStateDesc.IndependentBlendEnable = mProperties.getIndependantBlendEnable();
for(UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
{
blendStateDesc.RenderTarget[i].BlendEnable = mProperties.getBlendEnabled(i);
blendStateDesc.RenderTarget[i].BlendOp = D3D11Mappings::get(mProperties.getBlendOperation(i));
blendStateDesc.RenderTarget[i].BlendOpAlpha = D3D11Mappings::get(mProperties.getAlphaBlendOperation(i));
blendStateDesc.RenderTarget[i].DestBlend = D3D11Mappings::get(mProperties.getDstBlend(i));
blendStateDesc.RenderTarget[i].DestBlendAlpha = D3D11Mappings::get(mProperties.getAlphaDstBlend(i));
blendStateDesc.RenderTarget[i].RenderTargetWriteMask = 0xf & (mProperties.getRenderTargetWriteMask(i)); // Mask out all but last 4 bits
blendStateDesc.RenderTarget[i].SrcBlend = D3D11Mappings::get(mProperties.getSrcBlend(i));
blendStateDesc.RenderTarget[i].SrcBlendAlpha = D3D11Mappings::get(mProperties.getAlphaSrcBlend(i));
}
D3D11RenderAPI* rs = static_cast<D3D11RenderAPI*>(RenderAPI::instancePtr());
D3D11Device& device = rs->getPrimaryDevice();
HRESULT hr = device.getD3D11Device()->CreateBlendState(&blendStateDesc, &mBlendState);
if(FAILED(hr) || device.hasError())
{
String errorDescription = device.getErrorDescription();
BS_EXCEPT(RenderingAPIException, "Cannot create blend state.\nError Description:" + errorDescription);
}
BS_INC_RENDER_STAT_CAT(ResCreated, RenderStatObject_BlendState);
BlendState::createInternal();
}