|
@@ -6,7 +6,7 @@ namespace CamelotEngine
|
|
|
{
|
|
{
|
|
|
MultiRenderTexture::MultiRenderTexture()
|
|
MultiRenderTexture::MultiRenderTexture()
|
|
|
{
|
|
{
|
|
|
- mSurfaces.resize(CM_MAX_MULTIPLE_RENDER_TARGETS);
|
|
|
|
|
|
|
+ mColorSurfaces.resize(CM_MAX_MULTIPLE_RENDER_TARGETS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void MultiRenderTexture::setColorSurface(UINT32 surfaceIdx, TexturePtr texture, UINT32 face, UINT32 numFaces, UINT32 mipLevel)
|
|
void MultiRenderTexture::setColorSurface(UINT32 surfaceIdx, TexturePtr texture, UINT32 face, UINT32 numFaces, UINT32 mipLevel)
|
|
@@ -17,14 +17,20 @@ namespace CamelotEngine
|
|
|
if(texture != nullptr && texture->getUsage() != TU_RENDERTARGET)
|
|
if(texture != nullptr && texture->getUsage() != TU_RENDERTARGET)
|
|
|
CM_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
|
|
CM_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
|
|
|
|
|
|
|
|
- mSurfaces[surfaceIdx].texture = texture;
|
|
|
|
|
|
|
+ if(mColorSurfaces[surfaceIdx] != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ mColorSurfaces[surfaceIdx]->getTexture()->releaseView(mColorSurfaces[surfaceIdx]);
|
|
|
|
|
+ mColorSurfaces[surfaceIdx] = nullptr;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if(texture == nullptr)
|
|
if(texture == nullptr)
|
|
|
{
|
|
{
|
|
|
setColorSurfaceImpl(surfaceIdx, texture, face, numFaces, mipLevel);
|
|
setColorSurfaceImpl(surfaceIdx, texture, face, numFaces, mipLevel);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ mColorSurfaces[surfaceIdx] = Texture::requestView(texture, mipLevel, 1, face, numFaces, GVU_RENDERTARGET);
|
|
|
|
|
+
|
|
|
mPriority = CM_REND_TO_TEX_RT_GROUP;
|
|
mPriority = CM_REND_TO_TEX_RT_GROUP;
|
|
|
mWidth = texture->getWidth();
|
|
mWidth = texture->getWidth();
|
|
|
mHeight = texture->getWidth();
|
|
mHeight = texture->getWidth();
|
|
@@ -34,52 +40,55 @@ namespace CamelotEngine
|
|
|
mFSAA = texture->getFSAA();
|
|
mFSAA = texture->getFSAA();
|
|
|
mFSAAHint = texture->getFSAAHint();
|
|
mFSAAHint = texture->getFSAAHint();
|
|
|
|
|
|
|
|
- mSurfaces[surfaceIdx].format = texture->getFormat();
|
|
|
|
|
-
|
|
|
|
|
- mSurfaces[surfaceIdx].face = face;
|
|
|
|
|
- mSurfaces[surfaceIdx].numFaces = numFaces;
|
|
|
|
|
- mSurfaces[surfaceIdx].mipLevel = mipLevel;
|
|
|
|
|
-
|
|
|
|
|
throwIfBuffersDontMatch();
|
|
throwIfBuffersDontMatch();
|
|
|
|
|
|
|
|
setColorSurfaceImpl(surfaceIdx, texture, face, numFaces, mipLevel);
|
|
setColorSurfaceImpl(surfaceIdx, texture, face, numFaces, mipLevel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void MultiRenderTexture::setDepthStencilSurface(TexturePtr depthStencilSurface)
|
|
|
|
|
|
|
+ void MultiRenderTexture::setDepthStencilSurface(TexturePtr depthStencil, UINT32 face, UINT32 numFaces, UINT32 mipLevel)
|
|
|
{
|
|
{
|
|
|
- if(depthStencilSurface != nullptr && depthStencilSurface->getUsage() != TU_DEPTHSTENCIL)
|
|
|
|
|
|
|
+ if(depthStencil != nullptr && depthStencil->getUsage() != TU_DEPTHSTENCIL)
|
|
|
CM_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
|
|
CM_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
|
|
|
|
|
|
|
|
- mDepthStencilSurface = depthStencilSurface;
|
|
|
|
|
|
|
+ if(mDepthStencilSurface != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ Texture::releaseView(mDepthStencilSurface);
|
|
|
|
|
+ mDepthStencilSurface = nullptr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(depthStencil == nullptr)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ mDepthStencilSurface = Texture::requestView(depthStencil, mipLevel, 1, face, numFaces, GVU_DEPTHSTENCIL);
|
|
|
|
|
|
|
|
throwIfBuffersDontMatch();
|
|
throwIfBuffersDontMatch();
|
|
|
|
|
|
|
|
- setDepthStencilImpl(depthStencilSurface);
|
|
|
|
|
|
|
+ setDepthStencilImpl(depthStencil, face, numFaces, mipLevel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void MultiRenderTexture::throwIfBuffersDontMatch() const
|
|
void MultiRenderTexture::throwIfBuffersDontMatch() const
|
|
|
{
|
|
{
|
|
|
- const SurfaceDesc* firstSurfaceDesc = nullptr;
|
|
|
|
|
- for(size_t i = 0; i < mSurfaces.size(); i++)
|
|
|
|
|
|
|
+ const TextureView* firstSurfaceDesc = nullptr;
|
|
|
|
|
+ for(size_t i = 0; i < mColorSurfaces.size(); i++)
|
|
|
{
|
|
{
|
|
|
- if(mSurfaces[i].texture == nullptr)
|
|
|
|
|
|
|
+ if(mColorSurfaces[i] == nullptr)
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
if(firstSurfaceDesc == nullptr)
|
|
if(firstSurfaceDesc == nullptr)
|
|
|
{
|
|
{
|
|
|
- firstSurfaceDesc = &mSurfaces[i];
|
|
|
|
|
|
|
+ firstSurfaceDesc = mColorSurfaces[i];
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(mSurfaces[i].texture->getWidth() != firstSurfaceDesc->texture->getWidth() ||
|
|
|
|
|
- mSurfaces[i].texture->getHeight() != firstSurfaceDesc->texture->getHeight() ||
|
|
|
|
|
- mSurfaces[i].texture->getFSAA() != firstSurfaceDesc->texture->getFSAA() ||
|
|
|
|
|
- mSurfaces[i].texture->getFSAAHint() != firstSurfaceDesc->texture->getFSAAHint())
|
|
|
|
|
|
|
+ if(mColorSurfaces[i]->getTexture()->getWidth() != firstSurfaceDesc->getTexture()->getWidth() ||
|
|
|
|
|
+ mColorSurfaces[i]->getTexture()->getHeight() != firstSurfaceDesc->getTexture()->getHeight() ||
|
|
|
|
|
+ mColorSurfaces[i]->getTexture()->getFSAA() != firstSurfaceDesc->getTexture()->getFSAA() ||
|
|
|
|
|
+ mColorSurfaces[i]->getTexture()->getFSAAHint() != firstSurfaceDesc->getTexture()->getFSAAHint())
|
|
|
{
|
|
{
|
|
|
- String errorInfo = "\nWidth: " + toString(mSurfaces[i].texture->getWidth()) + "/" + toString(firstSurfaceDesc->texture->getWidth());
|
|
|
|
|
- errorInfo += "\nHeight: " + toString(mSurfaces[i].texture->getHeight()) + "/" + toString(firstSurfaceDesc->texture->getHeight());
|
|
|
|
|
- errorInfo += "\nFSAA: " + toString(mSurfaces[i].texture->getFSAA()) + "/" + toString(firstSurfaceDesc->texture->getFSAA());
|
|
|
|
|
- errorInfo += "\nFSAAHint: " + mSurfaces[i].texture->getFSAAHint() + "/" + firstSurfaceDesc->texture->getFSAAHint();
|
|
|
|
|
|
|
+ String errorInfo = "\nWidth: " + toString(mColorSurfaces[i]->getTexture()->getWidth()) + "/" + toString(firstSurfaceDesc->getTexture()->getWidth());
|
|
|
|
|
+ errorInfo += "\nHeight: " + toString(mColorSurfaces[i]->getTexture()->getHeight()) + "/" + toString(firstSurfaceDesc->getTexture()->getHeight());
|
|
|
|
|
+ errorInfo += "\nFSAA: " + toString(mColorSurfaces[i]->getTexture()->getFSAA()) + "/" + toString(firstSurfaceDesc->getTexture()->getFSAA());
|
|
|
|
|
+ errorInfo += "\nFSAAHint: " + mColorSurfaces[i]->getTexture()->getFSAAHint() + "/" + firstSurfaceDesc->getTexture()->getFSAAHint();
|
|
|
|
|
|
|
|
CM_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
|
|
CM_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
|
|
|
}
|
|
}
|
|
@@ -88,33 +97,33 @@ namespace CamelotEngine
|
|
|
if(firstSurfaceDesc == nullptr)
|
|
if(firstSurfaceDesc == nullptr)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- if(firstSurfaceDesc->texture->getTextureType() != TEX_TYPE_2D)
|
|
|
|
|
|
|
+ if(firstSurfaceDesc->getTexture()->getTextureType() != TEX_TYPE_2D)
|
|
|
CM_EXCEPT(NotImplementedException, "Render textures are currently only implemented for 2D surfaces.");
|
|
CM_EXCEPT(NotImplementedException, "Render textures are currently only implemented for 2D surfaces.");
|
|
|
|
|
|
|
|
- if((firstSurfaceDesc->face + firstSurfaceDesc->numFaces) >= firstSurfaceDesc->texture->getNumFaces())
|
|
|
|
|
|
|
+ if((firstSurfaceDesc->getFirstArraySlice() + firstSurfaceDesc->getNumArraySlices()) >= firstSurfaceDesc->getTexture()->getNumFaces())
|
|
|
{
|
|
{
|
|
|
CM_EXCEPT(InvalidParametersException, "Provided number of faces is out of range. Face: " +
|
|
CM_EXCEPT(InvalidParametersException, "Provided number of faces is out of range. Face: " +
|
|
|
- toString(firstSurfaceDesc->face + firstSurfaceDesc->numFaces) + ". Max num faces: " + toString(firstSurfaceDesc->texture->getNumFaces()));
|
|
|
|
|
|
|
+ toString(firstSurfaceDesc->getFirstArraySlice() + firstSurfaceDesc->getNumArraySlices()) + ". Max num faces: " + toString(firstSurfaceDesc->getTexture()->getNumFaces()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(firstSurfaceDesc->mipLevel >= firstSurfaceDesc->texture->getNumMipmaps())
|
|
|
|
|
|
|
+ if(firstSurfaceDesc->getMostDetailedMip() >= firstSurfaceDesc->getTexture()->getNumMipmaps())
|
|
|
{
|
|
{
|
|
|
CM_EXCEPT(InvalidParametersException, "Provided number of mip maps is out of range. Mip level: " +
|
|
CM_EXCEPT(InvalidParametersException, "Provided number of mip maps is out of range. Mip level: " +
|
|
|
- toString(firstSurfaceDesc->mipLevel) + ". Max num mipmaps: " + toString(firstSurfaceDesc->texture->getNumMipmaps()));
|
|
|
|
|
|
|
+ toString(firstSurfaceDesc->getMostDetailedMip()) + ". Max num mipmaps: " + toString(firstSurfaceDesc->getTexture()->getNumMipmaps()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(mDepthStencilSurface == nullptr)
|
|
if(mDepthStencilSurface == nullptr)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- if(mDepthStencilSurface->getWidth() != firstSurfaceDesc->texture->getWidth() ||
|
|
|
|
|
- mDepthStencilSurface->getHeight() != firstSurfaceDesc->texture->getHeight() ||
|
|
|
|
|
- mDepthStencilSurface->getFSAA() != firstSurfaceDesc->texture->getFSAA() ||
|
|
|
|
|
- mDepthStencilSurface->getFSAAHint() != firstSurfaceDesc->texture->getFSAAHint())
|
|
|
|
|
|
|
+ if(mDepthStencilSurface->getTexture()->getWidth() != firstSurfaceDesc->getTexture()->getWidth() ||
|
|
|
|
|
+ mDepthStencilSurface->getTexture()->getHeight() != firstSurfaceDesc->getTexture()->getHeight() ||
|
|
|
|
|
+ mDepthStencilSurface->getTexture()->getFSAA() != firstSurfaceDesc->getTexture()->getFSAA() ||
|
|
|
|
|
+ mDepthStencilSurface->getTexture()->getFSAAHint() != firstSurfaceDesc->getTexture()->getFSAAHint())
|
|
|
{
|
|
{
|
|
|
- String errorInfo = "\nWidth: " + toString(mDepthStencilSurface->getWidth()) + "/" + toString(firstSurfaceDesc->texture->getWidth());
|
|
|
|
|
- errorInfo += "\nHeight: " + toString(mDepthStencilSurface->getHeight()) + "/" + toString(firstSurfaceDesc->texture->getHeight());
|
|
|
|
|
- errorInfo += "\nFSAA: " + toString(mDepthStencilSurface->getFSAA()) + "/" + toString(firstSurfaceDesc->texture->getFSAA());
|
|
|
|
|
- errorInfo += "\nFSAAHint: " + mDepthStencilSurface->getFSAAHint() + "/" + firstSurfaceDesc->texture->getFSAAHint();
|
|
|
|
|
|
|
+ String errorInfo = "\nWidth: " + toString(mDepthStencilSurface->getTexture()->getWidth()) + "/" + toString(firstSurfaceDesc->getTexture()->getWidth());
|
|
|
|
|
+ errorInfo += "\nHeight: " + toString(mDepthStencilSurface->getTexture()->getHeight()) + "/" + toString(firstSurfaceDesc->getTexture()->getHeight());
|
|
|
|
|
+ errorInfo += "\nFSAA: " + toString(mDepthStencilSurface->getTexture()->getFSAA()) + "/" + toString(firstSurfaceDesc->getTexture()->getFSAA());
|
|
|
|
|
+ errorInfo += "\nFSAAHint: " + mDepthStencilSurface->getTexture()->getFSAAHint() + "/" + firstSurfaceDesc->getTexture()->getFSAAHint();
|
|
|
|
|
|
|
|
CM_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
|
|
CM_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
|
|
|
}
|
|
}
|