|
@@ -12,28 +12,34 @@ namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping)
|
|
RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping)
|
|
|
{
|
|
{
|
|
|
- HTexture texture = desc.colorSurface.texture;
|
|
|
|
|
-
|
|
|
|
|
- if (texture.isLoaded())
|
|
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
{
|
|
{
|
|
|
- const TextureProperties& props = texture->getProperties();
|
|
|
|
|
- construct(&props, requiresFlipping);
|
|
|
|
|
|
|
+ HTexture texture = desc.colorSurfaces[i].texture;
|
|
|
|
|
+
|
|
|
|
|
+ if (texture.isLoaded())
|
|
|
|
|
+ {
|
|
|
|
|
+ const TextureProperties& texProps = texture->getProperties();
|
|
|
|
|
+ construct(&texProps, requiresFlipping);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
- construct(nullptr, requiresFlipping);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_CORE_DESC& desc, bool requiresFlipping)
|
|
|
|
|
|
|
+ RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC_CORE& desc, bool requiresFlipping)
|
|
|
{
|
|
{
|
|
|
- SPtr<TextureCore> texture = desc.colorSurface.texture;
|
|
|
|
|
-
|
|
|
|
|
- if (texture != nullptr)
|
|
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
{
|
|
{
|
|
|
- const TextureProperties& props = texture->getProperties();
|
|
|
|
|
- construct(&props, requiresFlipping);
|
|
|
|
|
|
|
+ SPtr<TextureCore> texture = desc.colorSurfaces[i].texture;
|
|
|
|
|
+
|
|
|
|
|
+ if (texture != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ const TextureProperties& texProps = texture->getProperties();
|
|
|
|
|
+ construct(&texProps, requiresFlipping);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
- construct(nullptr, requiresFlipping);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void RenderTextureProperties::construct(const TextureProperties* textureProps, bool requiresFlipping)
|
|
void RenderTextureProperties::construct(const TextureProperties* textureProps, bool requiresFlipping)
|
|
@@ -52,14 +58,17 @@ namespace BansheeEngine
|
|
|
mRequiresTextureFlipping = requiresFlipping;
|
|
mRequiresTextureFlipping = requiresFlipping;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc)
|
|
|
|
|
- :mColorSurface(nullptr), mDepthStencilSurface(nullptr), mDesc(desc)
|
|
|
|
|
|
|
+ RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc)
|
|
|
|
|
+ :mDesc(desc)
|
|
|
{ }
|
|
{ }
|
|
|
|
|
|
|
|
RenderTextureCore::~RenderTextureCore()
|
|
RenderTextureCore::~RenderTextureCore()
|
|
|
{
|
|
{
|
|
|
- if (mColorSurface != nullptr)
|
|
|
|
|
- TextureCore::releaseView(mColorSurface);
|
|
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (mColorSurfaces[i] != nullptr)
|
|
|
|
|
+ TextureCore::releaseView(mColorSurfaces[i]);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (mDepthStencilSurface != nullptr)
|
|
if (mDepthStencilSurface != nullptr)
|
|
|
TextureCore::releaseView(mDepthStencilSurface);
|
|
TextureCore::releaseView(mDepthStencilSurface);
|
|
@@ -69,61 +78,35 @@ namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
RenderTargetCore::initialize();
|
|
RenderTargetCore::initialize();
|
|
|
|
|
|
|
|
- const RENDER_SURFACE_CORE_DESC& colorSurface = mDesc.colorSurface;
|
|
|
|
|
- if (colorSurface.texture != nullptr)
|
|
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
{
|
|
{
|
|
|
- SPtr<TextureCore> texture = colorSurface.texture;
|
|
|
|
|
|
|
+ if (mDesc.colorSurfaces[i].texture != nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ SPtr<TextureCore> texture = mDesc.colorSurfaces[i].texture;
|
|
|
|
|
|
|
|
- if (texture->getProperties().getUsage() != TU_RENDERTARGET)
|
|
|
|
|
- BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
|
|
|
|
|
|
|
+ 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);
|
|
|
|
|
|
|
+ mColorSurfaces[i] = TextureCore::requestView(texture, mDesc.colorSurfaces[i].mipLevel, 1,
|
|
|
|
|
+ mDesc.colorSurfaces[i].face, mDesc.colorSurfaces[i].numFaces, GVU_RENDERTARGET);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const RENDER_SURFACE_CORE_DESC& depthStencilSurface = mDesc.depthStencilSurface;
|
|
|
|
|
- if (depthStencilSurface.texture != nullptr)
|
|
|
|
|
|
|
+ if (mDesc.depthStencilSurface.texture != nullptr)
|
|
|
{
|
|
{
|
|
|
- SPtr<TextureCore> texture = depthStencilSurface.texture;
|
|
|
|
|
|
|
+ SPtr<TextureCore> texture = mDesc.depthStencilSurface.texture;
|
|
|
|
|
|
|
|
if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
|
|
if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
|
|
|
BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
|
|
BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
|
|
|
|
|
|
|
|
- mDepthStencilSurface = TextureCore::requestView(texture, depthStencilSurface.mipLevel, 1,
|
|
|
|
|
- depthStencilSurface.face, 0, GVU_DEPTHSTENCIL);
|
|
|
|
|
|
|
+ mDepthStencilSurface = TextureCore::requestView(texture, mDesc.depthStencilSurface.mipLevel, 1,
|
|
|
|
|
+ mDesc.depthStencilSurface.face, 0, GVU_DEPTHSTENCIL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
throwIfBuffersDontMatch();
|
|
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()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- SPtr<RenderTextureCore> RenderTextureCore::create(const RENDER_TEXTURE_CORE_DESC& desc)
|
|
|
|
|
|
|
+ SPtr<RenderTextureCore> RenderTextureCore::create(const RENDER_TEXTURE_DESC_CORE& desc)
|
|
|
{
|
|
{
|
|
|
return TextureCoreManager::instance().createRenderTexture(desc);
|
|
return TextureCoreManager::instance().createRenderTexture(desc);
|
|
|
}
|
|
}
|
|
@@ -141,30 +124,87 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
void RenderTextureCore::throwIfBuffersDontMatch() const
|
|
void RenderTextureCore::throwIfBuffersDontMatch() const
|
|
|
{
|
|
{
|
|
|
- if (mColorSurface == nullptr || mDepthStencilSurface == nullptr)
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ SPtr<TextureView> firstSurfaceDesc = nullptr;
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (mColorSurfaces[i] == nullptr)
|
|
|
|
|
+ continue;
|
|
|
|
|
|
|
|
- const TextureProperties& colorProps = mColorSurface->getTexture()->getProperties();
|
|
|
|
|
- const TextureProperties& depthProps = mDepthStencilSurface->getTexture()->getProperties();
|
|
|
|
|
|
|
+ if (firstSurfaceDesc == nullptr)
|
|
|
|
|
+ {
|
|
|
|
|
+ firstSurfaceDesc = mColorSurfaces[i];
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- UINT32 colorMsCount = colorProps.getMultisampleCount();
|
|
|
|
|
- UINT32 depthMsCount = depthProps.getMultisampleCount();
|
|
|
|
|
|
|
+ const TextureProperties& curTexProps = mColorSurfaces[i]->getTexture()->getProperties();
|
|
|
|
|
+ const TextureProperties& firstTexProps = firstSurfaceDesc->getTexture()->getProperties();
|
|
|
|
|
|
|
|
- if (colorMsCount == 0)
|
|
|
|
|
- colorMsCount = 1;
|
|
|
|
|
|
|
+ UINT32 curMsCount = curTexProps.getMultisampleCount();
|
|
|
|
|
+ UINT32 firstMsCount = firstTexProps.getMultisampleCount();
|
|
|
|
|
|
|
|
- if (depthMsCount == 0)
|
|
|
|
|
- depthMsCount = 1;
|
|
|
|
|
|
|
+ if (curMsCount == 0)
|
|
|
|
|
+ curMsCount = 1;
|
|
|
|
|
|
|
|
- if (colorProps.getWidth() != depthProps.getWidth() ||
|
|
|
|
|
- colorProps.getHeight() != depthProps.getHeight() ||
|
|
|
|
|
- colorMsCount != depthMsCount)
|
|
|
|
|
|
|
+ if (firstMsCount == 0)
|
|
|
|
|
+ firstMsCount = 1;
|
|
|
|
|
+
|
|
|
|
|
+ if (curTexProps.getWidth() != firstTexProps.getWidth() ||
|
|
|
|
|
+ curTexProps.getHeight() != firstTexProps.getHeight() ||
|
|
|
|
|
+ curMsCount != firstMsCount)
|
|
|
|
|
+ {
|
|
|
|
|
+ String errorInfo = "\nWidth: " + toString(curTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
|
|
|
|
|
+ errorInfo += "\nHeight: " + toString(curTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
|
|
|
|
|
+ errorInfo += "\nMultisample Count: " + toString(curMsCount) + "/" + toString(firstMsCount);
|
|
|
|
|
+
|
|
|
|
|
+ BS_EXCEPT(InvalidParametersException, "Provided color textures don't match!" + errorInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (firstSurfaceDesc != nullptr)
|
|
|
{
|
|
{
|
|
|
- String errorInfo = "\nWidth: " + toString(colorProps.getWidth()) + "/" + toString(depthProps.getWidth());
|
|
|
|
|
- errorInfo += "\nHeight: " + toString(colorProps.getHeight()) + "/" + toString(depthProps.getHeight());
|
|
|
|
|
- errorInfo += "\nMultisample Count: " + toString(colorMsCount) + "/" + toString(depthMsCount);
|
|
|
|
|
|
|
+ const TextureProperties& firstTexProps = firstSurfaceDesc->getTexture()->getProperties();
|
|
|
|
|
+
|
|
|
|
|
+ UINT32 numSlices;
|
|
|
|
|
+ if (firstTexProps.getTextureType() == TEX_TYPE_3D)
|
|
|
|
|
+ numSlices = firstTexProps.getDepth();
|
|
|
|
|
+ else
|
|
|
|
|
+ numSlices = firstTexProps.getNumFaces();
|
|
|
|
|
+
|
|
|
|
|
+ if ((firstSurfaceDesc->getFirstArraySlice() + firstSurfaceDesc->getNumArraySlices()) > numSlices)
|
|
|
|
|
+ {
|
|
|
|
|
+ BS_EXCEPT(InvalidParametersException, "Provided number of faces is out of range. Face: " +
|
|
|
|
|
+ toString(firstSurfaceDesc->getFirstArraySlice() + firstSurfaceDesc->getNumArraySlices()) + ". Max num faces: " + toString(numSlices));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
|
|
|
|
|
|
|
+ if (firstSurfaceDesc->getMostDetailedMip() > firstTexProps.getNumMipmaps())
|
|
|
|
|
+ {
|
|
|
|
|
+ BS_EXCEPT(InvalidParametersException, "Provided number of mip maps is out of range. Mip level: " +
|
|
|
|
|
+ toString(firstSurfaceDesc->getMostDetailedMip()) + ". Max num mipmaps: " + toString(firstTexProps.getNumMipmaps()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (mDepthStencilSurface == nullptr)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ const TextureProperties& depthTexProps = mDepthStencilSurface->getTexture()->getProperties();
|
|
|
|
|
+ UINT32 depthMsCount = depthTexProps.getMultisampleCount();
|
|
|
|
|
+ UINT32 colorMsCount = firstTexProps.getMultisampleCount();
|
|
|
|
|
+
|
|
|
|
|
+ if (depthMsCount == 0)
|
|
|
|
|
+ depthMsCount = 1;
|
|
|
|
|
+
|
|
|
|
|
+ if (colorMsCount == 0)
|
|
|
|
|
+ colorMsCount = 1;
|
|
|
|
|
+
|
|
|
|
|
+ if (depthTexProps.getWidth() != firstTexProps.getWidth() ||
|
|
|
|
|
+ depthTexProps.getHeight() != firstTexProps.getHeight() ||
|
|
|
|
|
+ depthMsCount != colorMsCount)
|
|
|
|
|
+ {
|
|
|
|
|
+ String errorInfo = "\nWidth: " + toString(depthTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
|
|
|
|
|
+ errorInfo += "\nHeight: " + toString(depthTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
|
|
|
|
|
+ errorInfo += "\nMultisample Count: " + toString(depthMsCount) + "/" + toString(colorMsCount);
|
|
|
|
|
+
|
|
|
|
|
+ BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -187,11 +227,13 @@ namespace BansheeEngine
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
RenderTexture::RenderTexture(const RENDER_TEXTURE_DESC& desc)
|
|
RenderTexture::RenderTexture(const RENDER_TEXTURE_DESC& desc)
|
|
|
|
|
+ :mDesc(desc)
|
|
|
{
|
|
{
|
|
|
- mDesc = desc;
|
|
|
|
|
-
|
|
|
|
|
- if (desc.colorSurface.texture != nullptr)
|
|
|
|
|
- mBindableColorTex = desc.colorSurface.texture;
|
|
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (desc.colorSurfaces[i].texture != nullptr)
|
|
|
|
|
+ mBindableColorTex[i] = desc.colorSurfaces[i].texture;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (desc.depthStencilSurface.texture != nullptr)
|
|
if (desc.depthStencilSurface.texture != nullptr)
|
|
|
mBindableDepthStencilTex = desc.depthStencilSurface.texture;
|
|
mBindableDepthStencilTex = desc.depthStencilSurface.texture;
|
|
@@ -199,17 +241,24 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
SPtr<CoreObjectCore> RenderTexture::createCore() const
|
|
SPtr<CoreObjectCore> RenderTexture::createCore() const
|
|
|
{
|
|
{
|
|
|
- RENDER_TEXTURE_CORE_DESC coreDesc;
|
|
|
|
|
|
|
+ RENDER_TEXTURE_DESC_CORE coreDesc;
|
|
|
|
|
|
|
|
- if (mDesc.colorSurface.texture.isLoaded())
|
|
|
|
|
- coreDesc.colorSurface.texture = mDesc.colorSurface.texture->getCore();
|
|
|
|
|
|
|
+ for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ RENDER_SURFACE_DESC_CORE surfaceDesc;
|
|
|
|
|
+ if (mDesc.colorSurfaces[i].texture.isLoaded())
|
|
|
|
|
+ surfaceDesc.texture = mDesc.colorSurfaces[i].texture->getCore();
|
|
|
|
|
+
|
|
|
|
|
+ surfaceDesc.face = mDesc.colorSurfaces[i].face;
|
|
|
|
|
+ surfaceDesc.numFaces = mDesc.colorSurfaces[i].numFaces;
|
|
|
|
|
+ surfaceDesc.mipLevel = mDesc.colorSurfaces[i].mipLevel;
|
|
|
|
|
+
|
|
|
|
|
+ coreDesc.colorSurfaces[i] = surfaceDesc;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (mDesc.depthStencilSurface.texture.isLoaded())
|
|
if (mDesc.depthStencilSurface.texture.isLoaded())
|
|
|
coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
|
|
coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
|
|
|
|
|
|
|
|
- coreDesc.colorSurface.face = mDesc.colorSurface.face;
|
|
|
|
|
- coreDesc.colorSurface.numFaces = mDesc.colorSurface.numFaces;
|
|
|
|
|
- coreDesc.colorSurface.mipLevel = mDesc.colorSurface.mipLevel;
|
|
|
|
|
coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
|
|
coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
|
|
|
coreDesc.depthStencilSurface.numFaces = mDesc.depthStencilSurface.numFaces;
|
|
coreDesc.depthStencilSurface.numFaces = mDesc.depthStencilSurface.numFaces;
|
|
|
coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;
|
|
coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;
|