Commit 18b75bad by Martin Radev Committed by Commit Bot

D3D11: Handle Clear* commands for layered framebuffers

According to the ANGLE_multiview spec, Clear* commands only affect the range of attached layers to the multi-view layered framebuffer. The patch extends ImageIndex so that the range of attached layers is tracked and a render target view can be created with that range of texture array slices attached. The special case of scissored clears for depth and stencil attachments is handled by instancing the same number of quads as there are views and selecting the layer within a geometry shader. BUG=angleproject:2062 TEST=angle_end2end_tests Change-Id: Ibea248b980513f83d918652030a72c62c7ecd88b Reviewed-on: https://chromium-review.googlesource.com/632256 Commit-Queue: Martin Radev <mradev@nvidia.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 12e957f8
...@@ -3072,7 +3072,7 @@ void Context::framebufferTextureMultiviewLayeredANGLE(GLenum target, ...@@ -3072,7 +3072,7 @@ void Context::framebufferTextureMultiviewLayeredANGLE(GLenum target,
{ {
Texture *textureObj = getTexture(texture); Texture *textureObj = getTexture(texture);
ImageIndex index = ImageIndex::Make2DArray(level, baseViewIndex); ImageIndex index = ImageIndex::Make2DArrayRange(level, baseViewIndex, numViews);
framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj, framebuffer->setAttachmentMultiviewLayered(this, GL_TEXTURE, attachment, index, textureObj,
numViews, baseViewIndex); numViews, baseViewIndex);
} }
......
...@@ -17,7 +17,8 @@ namespace gl ...@@ -17,7 +17,8 @@ namespace gl
ImageIndex::ImageIndex(const ImageIndex &other) ImageIndex::ImageIndex(const ImageIndex &other)
: type(other.type), : type(other.type),
mipIndex(other.mipIndex), mipIndex(other.mipIndex),
layerIndex(other.layerIndex) layerIndex(other.layerIndex),
numLayers(other.numLayers)
{} {}
ImageIndex &ImageIndex::operator=(const ImageIndex &other) ImageIndex &ImageIndex::operator=(const ImageIndex &other)
...@@ -25,6 +26,7 @@ ImageIndex &ImageIndex::operator=(const ImageIndex &other) ...@@ -25,6 +26,7 @@ ImageIndex &ImageIndex::operator=(const ImageIndex &other)
type = other.type; type = other.type;
mipIndex = other.mipIndex; mipIndex = other.mipIndex;
layerIndex = other.layerIndex; layerIndex = other.layerIndex;
numLayers = other.numLayers;
return *this; return *this;
} }
...@@ -35,29 +37,34 @@ bool ImageIndex::is3D() const ...@@ -35,29 +37,34 @@ bool ImageIndex::is3D() const
ImageIndex ImageIndex::Make2D(GLint mipIndex) ImageIndex ImageIndex::Make2D(GLint mipIndex)
{ {
return ImageIndex(GL_TEXTURE_2D, mipIndex, ENTIRE_LEVEL); return ImageIndex(GL_TEXTURE_2D, mipIndex, ENTIRE_LEVEL, 1);
} }
ImageIndex ImageIndex::MakeRectangle(GLint mipIndex) ImageIndex ImageIndex::MakeRectangle(GLint mipIndex)
{ {
return ImageIndex(GL_TEXTURE_RECTANGLE_ANGLE, mipIndex, ENTIRE_LEVEL); return ImageIndex(GL_TEXTURE_RECTANGLE_ANGLE, mipIndex, ENTIRE_LEVEL, 1);
} }
ImageIndex ImageIndex::MakeCube(GLenum target, GLint mipIndex) ImageIndex ImageIndex::MakeCube(GLenum target, GLint mipIndex)
{ {
ASSERT(gl::IsCubeMapTextureTarget(target)); ASSERT(gl::IsCubeMapTextureTarget(target));
return ImageIndex(target, mipIndex, return ImageIndex(target, mipIndex,
static_cast<GLint>(CubeMapTextureTargetToLayerIndex(target))); static_cast<GLint>(CubeMapTextureTargetToLayerIndex(target)), 1);
} }
ImageIndex ImageIndex::Make2DArray(GLint mipIndex, GLint layerIndex) ImageIndex ImageIndex::Make2DArray(GLint mipIndex, GLint layerIndex)
{ {
return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex); return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex, 1);
}
ImageIndex ImageIndex::Make2DArrayRange(GLint mipIndex, GLint layerIndex, GLint numLayers)
{
return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex, numLayers);
} }
ImageIndex ImageIndex::Make3D(GLint mipIndex, GLint layerIndex) ImageIndex ImageIndex::Make3D(GLint mipIndex, GLint layerIndex)
{ {
return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex); return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex, 1);
} }
ImageIndex ImageIndex::MakeGeneric(GLenum target, GLint mipIndex) ImageIndex ImageIndex::MakeGeneric(GLenum target, GLint mipIndex)
...@@ -65,17 +72,17 @@ ImageIndex ImageIndex::MakeGeneric(GLenum target, GLint mipIndex) ...@@ -65,17 +72,17 @@ ImageIndex ImageIndex::MakeGeneric(GLenum target, GLint mipIndex)
GLint layerIndex = IsCubeMapTextureTarget(target) GLint layerIndex = IsCubeMapTextureTarget(target)
? static_cast<GLint>(CubeMapTextureTargetToLayerIndex(target)) ? static_cast<GLint>(CubeMapTextureTargetToLayerIndex(target))
: ENTIRE_LEVEL; : ENTIRE_LEVEL;
return ImageIndex(target, mipIndex, layerIndex); return ImageIndex(target, mipIndex, layerIndex, 1);
} }
ImageIndex ImageIndex::Make2DMultisample() ImageIndex ImageIndex::Make2DMultisample()
{ {
return ImageIndex(GL_TEXTURE_2D_MULTISAMPLE, 0, ENTIRE_LEVEL); return ImageIndex(GL_TEXTURE_2D_MULTISAMPLE, 0, ENTIRE_LEVEL, 1);
} }
ImageIndex ImageIndex::MakeInvalid() ImageIndex ImageIndex::MakeInvalid()
{ {
return ImageIndex(GL_NONE, -1, -1); return ImageIndex(GL_NONE, -1, -1, -1);
} }
bool ImageIndex::operator<(const ImageIndex &other) const bool ImageIndex::operator<(const ImageIndex &other) const
...@@ -88,15 +95,20 @@ bool ImageIndex::operator<(const ImageIndex &other) const ...@@ -88,15 +95,20 @@ bool ImageIndex::operator<(const ImageIndex &other) const
{ {
return mipIndex < other.mipIndex; return mipIndex < other.mipIndex;
} }
else else if (layerIndex != other.layerIndex)
{ {
return layerIndex < other.layerIndex; return layerIndex < other.layerIndex;
} }
else
{
return numLayers < other.numLayers;
}
} }
bool ImageIndex::operator==(const ImageIndex &other) const bool ImageIndex::operator==(const ImageIndex &other) const
{ {
return (type == other.type) && (mipIndex == other.mipIndex) && (layerIndex == other.layerIndex); return (type == other.type) && (mipIndex == other.mipIndex) &&
(layerIndex == other.layerIndex) && (numLayers == other.numLayers);
} }
bool ImageIndex::operator!=(const ImageIndex &other) const bool ImageIndex::operator!=(const ImageIndex &other) const
...@@ -104,10 +116,8 @@ bool ImageIndex::operator!=(const ImageIndex &other) const ...@@ -104,10 +116,8 @@ bool ImageIndex::operator!=(const ImageIndex &other) const
return !(*this == other); return !(*this == other);
} }
ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn) ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn, GLint numLayersIn)
: type(typeIn), : type(typeIn), mipIndex(mipIndexIn), layerIndex(layerIndexIn), numLayers(numLayersIn)
mipIndex(mipIndexIn),
layerIndex(layerIndexIn)
{} {}
ImageIndexIterator ImageIndexIterator::Make2D(GLint minMip, GLint maxMip) ImageIndexIterator ImageIndexIterator::Make2D(GLint minMip, GLint maxMip)
...@@ -213,7 +223,7 @@ ImageIndex ImageIndexIterator::next() ...@@ -213,7 +223,7 @@ ImageIndex ImageIndexIterator::next()
ImageIndex ImageIndexIterator::current() const ImageIndex ImageIndexIterator::current() const
{ {
ImageIndex value(mType, mCurrentMip, mCurrentLayer); ImageIndex value(mType, mCurrentMip, mCurrentLayer, 1);
if (mType == GL_TEXTURE_CUBE_MAP) if (mType == GL_TEXTURE_CUBE_MAP)
{ {
......
...@@ -23,6 +23,7 @@ struct ImageIndex ...@@ -23,6 +23,7 @@ struct ImageIndex
GLenum type; GLenum type;
GLint mipIndex; GLint mipIndex;
GLint layerIndex; GLint layerIndex;
GLint numLayers;
ImageIndex(const ImageIndex &other); ImageIndex(const ImageIndex &other);
ImageIndex &operator=(const ImageIndex &other); ImageIndex &operator=(const ImageIndex &other);
...@@ -34,6 +35,7 @@ struct ImageIndex ...@@ -34,6 +35,7 @@ struct ImageIndex
static ImageIndex MakeRectangle(GLint mipIndex); static ImageIndex MakeRectangle(GLint mipIndex);
static ImageIndex MakeCube(GLenum target, GLint mipIndex); static ImageIndex MakeCube(GLenum target, GLint mipIndex);
static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex); static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex);
static ImageIndex Make2DArrayRange(GLint mipIndex, GLint layerIndex, GLint numLayers);
static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = ENTIRE_LEVEL); static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = ENTIRE_LEVEL);
static ImageIndex MakeGeneric(GLenum target, GLint mipIndex); static ImageIndex MakeGeneric(GLenum target, GLint mipIndex);
static ImageIndex Make2DMultisample(); static ImageIndex Make2DMultisample();
...@@ -49,7 +51,7 @@ struct ImageIndex ...@@ -49,7 +51,7 @@ struct ImageIndex
private: private:
friend class ImageIndexIterator; friend class ImageIndexIterator;
ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn); ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn, GLint numLayersIn);
}; };
class ImageIndexIterator class ImageIndexIterator
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
// Precompiled shaders // Precompiled shaders
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clear11_fl9vs.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clear11_fl9vs.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clear11multiviewgs.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clear11multiviewvs.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clear11vs.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clear11vs.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/cleardepth11ps.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/cleardepth11ps.h"
#include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clearfloat11_fl9ps.h" #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/clearfloat11_fl9ps.h"
...@@ -125,6 +127,8 @@ Clear11::ShaderManager::ShaderManager() ...@@ -125,6 +127,8 @@ Clear11::ShaderManager::ShaderManager()
mVs9(g_VS_Clear_FL9, ArraySize(g_VS_Clear_FL9), "Clear11 VS FL9"), mVs9(g_VS_Clear_FL9, ArraySize(g_VS_Clear_FL9), "Clear11 VS FL9"),
mPsFloat9(g_PS_ClearFloat_FL9, ArraySize(g_PS_ClearFloat_FL9), "Clear11 PS FloatFL9"), mPsFloat9(g_PS_ClearFloat_FL9, ArraySize(g_PS_ClearFloat_FL9), "Clear11 PS FloatFL9"),
mVs(g_VS_Clear, ArraySize(g_VS_Clear), "Clear11 VS"), mVs(g_VS_Clear, ArraySize(g_VS_Clear), "Clear11 VS"),
mVsMultiview(g_VS_Multiview_Clear, ArraySize(g_VS_Multiview_Clear), "Clear11 VS Multiview"),
mGsMultiview(g_GS_Multiview_Clear, ArraySize(g_GS_Multiview_Clear), "Clear11 GS Multiview"),
mPsDepth(g_PS_ClearDepth, ArraySize(g_PS_ClearDepth), "Clear11 PS Depth"), mPsDepth(g_PS_ClearDepth, ArraySize(g_PS_ClearDepth), "Clear11 PS Depth"),
mPsFloat{{CLEARPS(Float1), CLEARPS(Float2), CLEARPS(Float3), CLEARPS(Float4), CLEARPS(Float5), mPsFloat{{CLEARPS(Float1), CLEARPS(Float2), CLEARPS(Float3), CLEARPS(Float4), CLEARPS(Float5),
CLEARPS(Float6), CLEARPS(Float7), CLEARPS(Float8)}}, CLEARPS(Float6), CLEARPS(Float7), CLEARPS(Float8)}},
...@@ -144,8 +148,10 @@ Clear11::ShaderManager::~ShaderManager() ...@@ -144,8 +148,10 @@ Clear11::ShaderManager::~ShaderManager()
gl::Error Clear11::ShaderManager::getShadersAndLayout(Renderer11 *renderer, gl::Error Clear11::ShaderManager::getShadersAndLayout(Renderer11 *renderer,
const INT clearType, const INT clearType,
const uint32_t numRTs, const uint32_t numRTs,
const bool hasLayeredLayout,
const d3d11::InputLayout **il, const d3d11::InputLayout **il,
const d3d11::VertexShader **vs, const d3d11::VertexShader **vs,
const d3d11::GeometryShader **gs,
const d3d11::PixelShader **ps) const d3d11::PixelShader **ps)
{ {
if (renderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_9_3) if (renderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_9_3)
...@@ -167,13 +173,26 @@ gl::Error Clear11::ShaderManager::getShadersAndLayout(Renderer11 *renderer, ...@@ -167,13 +173,26 @@ gl::Error Clear11::ShaderManager::getShadersAndLayout(Renderer11 *renderer,
} }
*vs = &mVs9.getObj(); *vs = &mVs9.getObj();
*gs = nullptr;
*il = &mIl9; *il = &mIl9;
*ps = &mPsFloat9.getObj(); *ps = &mPsFloat9.getObj();
return gl::NoError(); return gl::NoError();
} }
if (!hasLayeredLayout)
{
ANGLE_TRY(mVs.resolve(renderer)); ANGLE_TRY(mVs.resolve(renderer));
*vs = &mVs.getObj(); *vs = &mVs.getObj();
*gs = nullptr;
}
else
{
// For layered framebuffers we have to use the multi-view versions of the VS and GS.
ANGLE_TRY(mVsMultiview.resolve(renderer));
ANGLE_TRY(mGsMultiview.resolve(renderer));
*vs = &mVsMultiview.getObj();
*gs = &mGsMultiview.getObj();
}
*il = nullptr; *il = nullptr;
if (numRTs == 0) if (numRTs == 0)
...@@ -771,14 +790,16 @@ gl::Error Clear11::clearFramebuffer(const gl::Context *context, ...@@ -771,14 +790,16 @@ gl::Error Clear11::clearFramebuffer(const gl::Context *context,
// Get Shaders // Get Shaders
const d3d11::VertexShader *vs = nullptr; const d3d11::VertexShader *vs = nullptr;
const d3d11::GeometryShader *gs = nullptr;
const d3d11::InputLayout *il = nullptr; const d3d11::InputLayout *il = nullptr;
const d3d11::PixelShader *ps = nullptr; const d3d11::PixelShader *ps = nullptr;
const bool hasLayeredLayout =
ANGLE_TRY(mShaderManager.getShadersAndLayout(mRenderer, clearParams.colorType, numRtvs, &il, (fboData.getMultiviewLayout() == GL_FRAMEBUFFER_MULTIVIEW_LAYERED_ANGLE);
&vs, &ps)); ANGLE_TRY(mShaderManager.getShadersAndLayout(mRenderer, clearParams.colorType, numRtvs,
hasLayeredLayout, &il, &vs, &gs, &ps));
// Apply Shaders // Apply Shaders
stateManager->setDrawShaders(vs, nullptr, ps); stateManager->setDrawShaders(vs, gs, ps);
ID3D11Buffer *constantBuffer = mConstantBuffer.get(); ID3D11Buffer *constantBuffer = mConstantBuffer.get();
deviceContext->PSSetConstantBuffers(0, 1, &constantBuffer); deviceContext->PSSetConstantBuffers(0, 1, &constantBuffer);
...@@ -812,8 +833,16 @@ gl::Error Clear11::clearFramebuffer(const gl::Context *context, ...@@ -812,8 +833,16 @@ gl::Error Clear11::clearFramebuffer(const gl::Context *context,
deviceContext->RSSetScissorRects(1, &scissorRects[i]); deviceContext->RSSetScissorRects(1, &scissorRects[i]);
} }
// Draw the fullscreen quad. // Draw the fullscreen quad.
if (!hasLayeredLayout || isSideBySideFBO)
{
deviceContext->Draw(6, 0); deviceContext->Draw(6, 0);
} }
else
{
ASSERT(hasLayeredLayout);
deviceContext->DrawInstanced(6, static_cast<UINT>(fboData.getNumViews()), 0, 0);
}
}
// Clean up // Clean up
mRenderer->markAllStateDirty(context); mRenderer->markAllStateDirty(context);
......
...@@ -51,8 +51,10 @@ class Clear11 : angle::NonCopyable ...@@ -51,8 +51,10 @@ class Clear11 : angle::NonCopyable
gl::Error getShadersAndLayout(Renderer11 *renderer, gl::Error getShadersAndLayout(Renderer11 *renderer,
const INT clearType, const INT clearType,
const uint32_t numRTs, const uint32_t numRTs,
const bool hasLayeredLayout,
const d3d11::InputLayout **il, const d3d11::InputLayout **il,
const d3d11::VertexShader **vs, const d3d11::VertexShader **vs,
const d3d11::GeometryShader **gs,
const d3d11::PixelShader **ps); const d3d11::PixelShader **ps);
private: private:
...@@ -62,6 +64,8 @@ class Clear11 : angle::NonCopyable ...@@ -62,6 +64,8 @@ class Clear11 : angle::NonCopyable
d3d11::LazyShader<ID3D11VertexShader> mVs9; d3d11::LazyShader<ID3D11VertexShader> mVs9;
d3d11::LazyShader<ID3D11PixelShader> mPsFloat9; d3d11::LazyShader<ID3D11PixelShader> mPsFloat9;
d3d11::LazyShader<ID3D11VertexShader> mVs; d3d11::LazyShader<ID3D11VertexShader> mVs;
d3d11::LazyShader<ID3D11VertexShader> mVsMultiview;
d3d11::LazyShader<ID3D11GeometryShader> mGsMultiview;
d3d11::LazyShader<ID3D11PixelShader> mPsDepth; d3d11::LazyShader<ID3D11PixelShader> mPsDepth;
std::array<d3d11::LazyShader<ID3D11PixelShader>, kNumShaders> mPsFloat; std::array<d3d11::LazyShader<ID3D11PixelShader>, kNumShaders> mPsFloat;
std::array<d3d11::LazyShader<ID3D11PixelShader>, kNumShaders> mPsUInt; std::array<d3d11::LazyShader<ID3D11PixelShader>, kNumShaders> mPsUInt;
......
...@@ -2621,12 +2621,13 @@ void TextureStorage11_2DArray::associateImage(Image11 *image, const gl::ImageInd ...@@ -2621,12 +2621,13 @@ void TextureStorage11_2DArray::associateImage(Image11 *image, const gl::ImageInd
{ {
const GLint level = index.mipIndex; const GLint level = index.mipIndex;
const GLint layerTarget = index.layerIndex; const GLint layerTarget = index.layerIndex;
const GLint numLayers = index.numLayers;
ASSERT(0 <= level && level < getLevelCount()); ASSERT(0 <= level && level < getLevelCount());
if (0 <= level && level < getLevelCount()) if (0 <= level && level < getLevelCount())
{ {
LevelLayerKey key(level, layerTarget); LevelLayerRangeKey key(level, layerTarget, numLayers);
mAssociatedImages[key] = image; mAssociatedImages[key] = image;
} }
} }
...@@ -2636,8 +2637,9 @@ void TextureStorage11_2DArray::verifyAssociatedImageValid(const gl::ImageIndex & ...@@ -2636,8 +2637,9 @@ void TextureStorage11_2DArray::verifyAssociatedImageValid(const gl::ImageIndex &
{ {
const GLint level = index.mipIndex; const GLint level = index.mipIndex;
const GLint layerTarget = index.layerIndex; const GLint layerTarget = index.layerIndex;
const GLint numLayers = index.numLayers;
LevelLayerKey key(level, layerTarget); LevelLayerRangeKey key(level, layerTarget, numLayers);
// This validation check should never return false. It means the Image/TextureStorage // This validation check should never return false. It means the Image/TextureStorage
// association is broken. // association is broken.
...@@ -2652,8 +2654,9 @@ void TextureStorage11_2DArray::disassociateImage(const gl::ImageIndex &index, ...@@ -2652,8 +2654,9 @@ void TextureStorage11_2DArray::disassociateImage(const gl::ImageIndex &index,
{ {
const GLint level = index.mipIndex; const GLint level = index.mipIndex;
const GLint layerTarget = index.layerIndex; const GLint layerTarget = index.layerIndex;
const GLint numLayers = index.numLayers;
LevelLayerKey key(level, layerTarget); LevelLayerRangeKey key(level, layerTarget, numLayers);
bool imageAssociationCorrect = (mAssociatedImages.find(key) != mAssociatedImages.end() && bool imageAssociationCorrect = (mAssociatedImages.find(key) != mAssociatedImages.end() &&
(mAssociatedImages[key] == expectedImage)); (mAssociatedImages[key] == expectedImage));
...@@ -2669,8 +2672,9 @@ gl::Error TextureStorage11_2DArray::releaseAssociatedImage(const gl::Context *co ...@@ -2669,8 +2672,9 @@ gl::Error TextureStorage11_2DArray::releaseAssociatedImage(const gl::Context *co
{ {
const GLint level = index.mipIndex; const GLint level = index.mipIndex;
const GLint layerTarget = index.layerIndex; const GLint layerTarget = index.layerIndex;
const GLint numLayers = index.numLayers;
LevelLayerKey key(level, layerTarget); LevelLayerRangeKey key(level, layerTarget, numLayers);
if (mAssociatedImages.find(key) != mAssociatedImages.end()) if (mAssociatedImages.find(key) != mAssociatedImages.end())
{ {
...@@ -2750,7 +2754,7 @@ gl::Error TextureStorage11_2DArray::createRenderTargetSRV(const TextureHelper11 ...@@ -2750,7 +2754,7 @@ gl::Error TextureStorage11_2DArray::createRenderTargetSRV(const TextureHelper11
srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + index.mipIndex; srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + index.mipIndex;
srvDesc.Texture2DArray.MipLevels = 1; srvDesc.Texture2DArray.MipLevels = 1;
srvDesc.Texture2DArray.FirstArraySlice = index.layerIndex; srvDesc.Texture2DArray.FirstArraySlice = index.layerIndex;
srvDesc.Texture2DArray.ArraySize = 1; srvDesc.Texture2DArray.ArraySize = index.numLayers;
ANGLE_TRY(mRenderer->allocateResource(srvDesc, texture.get(), srv)); ANGLE_TRY(mRenderer->allocateResource(srvDesc, texture.get(), srv));
...@@ -2765,10 +2769,11 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::Context *context, ...@@ -2765,10 +2769,11 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::Context *context,
const int mipLevel = index.mipIndex; const int mipLevel = index.mipIndex;
const int layer = index.layerIndex; const int layer = index.layerIndex;
const int numLayers = index.numLayers;
ASSERT(mipLevel >= 0 && mipLevel < getLevelCount()); ASSERT(mipLevel >= 0 && mipLevel < getLevelCount());
LevelLayerKey key(mipLevel, layer); LevelLayerRangeKey key(mipLevel, layer, numLayers);
if (mRenderTargets.find(key) == mRenderTargets.end()) if (mRenderTargets.find(key) == mRenderTargets.end())
{ {
const TextureHelper11 *texture = nullptr; const TextureHelper11 *texture = nullptr;
...@@ -2794,7 +2799,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::Context *context, ...@@ -2794,7 +2799,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::Context *context,
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel; rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture2DArray.FirstArraySlice = layer; rtvDesc.Texture2DArray.FirstArraySlice = layer;
rtvDesc.Texture2DArray.ArraySize = 1; rtvDesc.Texture2DArray.ArraySize = numLayers;
d3d11::RenderTargetView rtv; d3d11::RenderTargetView rtv;
ANGLE_TRY(mRenderer->allocateResource(rtvDesc, texture->get(), &rtv)); ANGLE_TRY(mRenderer->allocateResource(rtvDesc, texture->get(), &rtv));
...@@ -2813,7 +2818,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::Context *context, ...@@ -2813,7 +2818,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::Context *context,
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY; dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel; dsvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
dsvDesc.Texture2DArray.FirstArraySlice = layer; dsvDesc.Texture2DArray.FirstArraySlice = layer;
dsvDesc.Texture2DArray.ArraySize = 1; dsvDesc.Texture2DArray.ArraySize = numLayers;
dsvDesc.Flags = 0; dsvDesc.Flags = 0;
d3d11::DepthStencilView dsv; d3d11::DepthStencilView dsv;
......
...@@ -485,6 +485,30 @@ class TextureStorage11_2DArray : public TextureStorage11 ...@@ -485,6 +485,30 @@ class TextureStorage11_2DArray : public TextureStorage11
gl::ErrorOrResult<DropStencil> ensureDropStencilTexture(const gl::Context *context) override; gl::ErrorOrResult<DropStencil> ensureDropStencilTexture(const gl::Context *context) override;
private: private:
struct LevelLayerRangeKey
{
LevelLayerRangeKey(int mipLevelIn, int layerIn, int numLayersIn)
: mipLevel(mipLevelIn), layer(layerIn), numLayers(numLayersIn)
{
}
bool operator<(const LevelLayerRangeKey &other) const
{
if (mipLevel != other.mipLevel)
{
return mipLevel < other.mipLevel;
}
if (layer != other.layer)
{
return layer < other.layer;
}
return numLayers < other.numLayers;
}
int mipLevel;
int layer;
int numLayers;
};
private:
gl::Error createSRV(const gl::Context *context, gl::Error createSRV(const gl::Context *context,
int baseLevel, int baseLevel,
int mipLevels, int mipLevels,
...@@ -496,8 +520,7 @@ class TextureStorage11_2DArray : public TextureStorage11 ...@@ -496,8 +520,7 @@ class TextureStorage11_2DArray : public TextureStorage11
DXGI_FORMAT resourceFormat, DXGI_FORMAT resourceFormat,
d3d11::SharedSRV *srv) const; d3d11::SharedSRV *srv) const;
typedef std::pair<int, int> LevelLayerKey; typedef std::map<LevelLayerRangeKey, RenderTarget11 *> RenderTargetMap;
typedef std::map<LevelLayerKey, RenderTarget11*> RenderTargetMap;
RenderTargetMap mRenderTargets; RenderTargetMap mRenderTargets;
TextureHelper11 mTexture; TextureHelper11 mTexture;
...@@ -505,7 +528,7 @@ class TextureStorage11_2DArray : public TextureStorage11 ...@@ -505,7 +528,7 @@ class TextureStorage11_2DArray : public TextureStorage11
TextureHelper11 mSwizzleTexture; TextureHelper11 mSwizzleTexture;
d3d11::RenderTargetView mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; d3d11::RenderTargetView mSwizzleRenderTargets[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
typedef std::map<LevelLayerKey, Image11*> ImageMap; typedef std::map<LevelLayerRangeKey, Image11 *> ImageMap;
ImageMap mAssociatedImages; ImageMap mAssociatedImages;
}; };
......
...@@ -30,12 +30,48 @@ void VS_Clear(in uint id : SV_VertexID, ...@@ -30,12 +30,48 @@ void VS_Clear(in uint id : SV_VertexID,
outPosition = float4(corner.x, corner.y, 0.0f, 1.0f); outPosition = float4(corner.x, corner.y, 0.0f, 1.0f);
} }
void VS_Multiview_Clear(in uint id : SV_VertexID,
in uint instanceID : SV_InstanceID,
out float4 outPosition : SV_POSITION,
out uint outLayerID : TEXCOORD0)
{
float2 corner = g_Corners[id];
outPosition = float4(corner.x, corner.y, 0.0f, 1.0f);
outLayerID = instanceID;
}
void VS_Clear_FL9( in float4 inPosition : POSITION, void VS_Clear_FL9( in float4 inPosition : POSITION,
out float4 outPosition : SV_POSITION) out float4 outPosition : SV_POSITION)
{ {
outPosition = inPosition; outPosition = inPosition;
} }
// Geometry shader for clearing multiview layered textures
struct GS_INPUT
{
float4 inPosition : SV_Position;
uint inLayerID : TEXCOORD0;
};
struct GS_OUTPUT
{
float4 outPosition : SV_Position;
uint outLayerID : SV_RenderTargetArrayIndex;
};
[maxvertexcount(3)]
void GS_Multiview_Clear(triangle GS_INPUT input[3], inout TriangleStream<GS_OUTPUT> outStream)
{
GS_OUTPUT output = (GS_OUTPUT)0;
for (int i = 0; i < 3; i++)
{
output.outPosition = input[i].inPosition;
output.outLayerID = input[i].inLayerID;
outStream.Append(output);
}
outStream.RestartStrip();
}
// Pixel Shader Constant Buffers // Pixel Shader Constant Buffers
cbuffer ColorAndDepthDataFloat : register(b0) cbuffer ColorAndDepthDataFloat : register(b0)
{ {
......
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float xyzw
// TEXCOORD 0 x 1 NONE uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float xyzw
// SV_RenderTargetArrayIndex 0 x 1 RTINDEX uint x
//
gs_4_0
dcl_input_siv v[3][0].xyzw, position
dcl_input v[3][1].x
dcl_temps 1
dcl_inputprimitive triangle
dcl_outputtopology trianglestrip
dcl_output_siv o0.xyzw, position
dcl_output_siv o1.x, rendertarget_array_index
dcl_maxout 3
mov r0.x, l(0)
loop
ige r0.y, r0.x, l(3)
breakc_nz r0.y
mov o0.xyzw, v[r0.x + 0][0].xyzw
mov o1.x, v[r0.x + 0][1].x
emit
iadd r0.x, r0.x, l(1)
endloop
cut
ret
// Approximately 11 instruction slots used
#endif
const BYTE g_GS_Multiview_Clear[] = {
68, 88, 66, 67, 244, 54, 208, 241, 128, 215, 208, 159, 113, 168, 148, 173, 167, 24, 78,
189, 1, 0, 0, 0, 216, 2, 0, 0, 5, 0, 0, 0, 52, 0, 0, 0, 140, 0,
0, 0, 228, 0, 0, 0, 76, 1, 0, 0, 92, 2, 0, 0, 82, 68, 69, 70, 80,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0,
0, 4, 83, 71, 0, 1, 0, 0, 28, 0, 0, 0, 77, 105, 99, 114, 111, 115, 111,
102, 116, 32, 40, 82, 41, 32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32,
67, 111, 109, 112, 105, 108, 101, 114, 32, 54, 46, 51, 46, 57, 54, 48, 48, 46, 49,
54, 51, 56, 52, 0, 171, 171, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0,
8, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0,
0, 0, 0, 0, 0, 15, 15, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 83, 86, 95, 80, 111,
115, 105, 116, 105, 111, 110, 0, 84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171,
79, 83, 71, 78, 96, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0,
0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 1,
0, 0, 0, 1, 14, 0, 0, 83, 86, 95, 80, 111, 115, 105, 116, 105, 111, 110, 0,
83, 86, 95, 82, 101, 110, 100, 101, 114, 84, 97, 114, 103, 101, 116, 65, 114, 114, 97,
121, 73, 110, 100, 101, 120, 0, 171, 171, 83, 72, 68, 82, 8, 1, 0, 0, 64, 0,
2, 0, 66, 0, 0, 0, 97, 0, 0, 5, 242, 16, 32, 0, 3, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 95, 0, 0, 4, 18, 16, 32, 0, 3, 0, 0, 0,
1, 0, 0, 0, 104, 0, 0, 2, 1, 0, 0, 0, 93, 24, 0, 1, 92, 40, 0,
1, 103, 0, 0, 4, 242, 32, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 103, 0,
0, 4, 18, 32, 16, 0, 1, 0, 0, 0, 4, 0, 0, 0, 94, 0, 0, 2, 3,
0, 0, 0, 54, 0, 0, 5, 18, 0, 16, 0, 0, 0, 0, 0, 1, 64, 0, 0,
0, 0, 0, 0, 48, 0, 0, 1, 33, 0, 0, 7, 34, 0, 16, 0, 0, 0, 0,
0, 10, 0, 16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 3, 0, 0, 0, 3, 0,
4, 3, 26, 0, 16, 0, 0, 0, 0, 0, 54, 0, 0, 7, 242, 32, 16, 0, 0,
0, 0, 0, 70, 30, 160, 0, 10, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54, 0, 0, 7, 18, 32, 16, 0, 1, 0, 0, 0, 10, 16, 160, 0, 10, 0, 16,
0, 0, 0, 0, 0, 1, 0, 0, 0, 19, 0, 0, 1, 30, 0, 0, 7, 18, 0,
16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 1,
0, 0, 0, 22, 0, 0, 1, 9, 0, 0, 1, 62, 0, 0, 1, 83, 84, 65, 84,
116, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0,
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 3, 0, 0, 0, 5, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0};
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VertexID 0 x 0 VERTID uint x
// SV_InstanceID 0 x 1 INSTID uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float xyzw
// TEXCOORD 0 x 1 NONE uint x
//
vs_4_0
dcl_immediateConstantBuffer { { -1.000000, 1.000000, 0, 0},
{ 1.000000, -1.000000, 0, 0},
{ -1.000000, -1.000000, 0, 0},
{ -1.000000, 1.000000, 0, 0},
{ 1.000000, 1.000000, 0, 0},
{ 1.000000, -1.000000, 0, 0} }
dcl_input_sgv v0.x, vertex_id
dcl_input_sgv v1.x, instance_id
dcl_output_siv o0.xyzw, position
dcl_output o1.x
dcl_temps 1
mov r0.x, v0.x
mov o0.xy, icb[r0.x + 0].xyxx
mov o0.zw, l(0,0,0,1.000000)
mov o1.x, v1.x
ret
// Approximately 5 instruction slots used
#endif
const BYTE g_VS_Multiview_Clear[] = {
68, 88, 66, 67, 45, 246, 70, 124, 58, 101, 157, 14, 171, 136, 167, 118, 133, 161, 59,
68, 1, 0, 0, 0, 220, 2, 0, 0, 5, 0, 0, 0, 52, 0, 0, 0, 140, 0,
0, 0, 232, 0, 0, 0, 64, 1, 0, 0, 96, 2, 0, 0, 82, 68, 69, 70, 80,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0,
0, 4, 254, 255, 0, 1, 0, 0, 28, 0, 0, 0, 77, 105, 99, 114, 111, 115, 111,
102, 116, 32, 40, 82, 41, 32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32,
67, 111, 109, 112, 105, 108, 101, 114, 32, 54, 46, 51, 46, 57, 54, 48, 48, 46, 49,
54, 51, 56, 52, 0, 171, 171, 73, 83, 71, 78, 84, 0, 0, 0, 2, 0, 0, 0,
8, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 1, 1, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 8, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 83, 86, 95, 86, 101,
114, 116, 101, 120, 73, 68, 0, 83, 86, 95, 73, 110, 115, 116, 97, 110, 99, 101, 73,
68, 0, 171, 171, 79, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0,
0, 56, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 1, 0, 0, 0, 1, 14, 0, 0, 83, 86, 95, 80, 79, 83, 73, 84,
73, 79, 78, 0, 84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171, 83, 72, 68,
82, 24, 1, 0, 0, 64, 0, 1, 0, 70, 0, 0, 0, 53, 24, 0, 0, 26, 0,
0, 0, 0, 0, 128, 191, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 63, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 191,
0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 191, 0, 0, 128,
63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 0, 0, 0,
0, 0, 0, 96, 0, 0, 4, 18, 16, 16, 0, 0, 0, 0, 0, 6, 0, 0, 0,
96, 0, 0, 4, 18, 16, 16, 0, 1, 0, 0, 0, 8, 0, 0, 0, 103, 0, 0,
4, 242, 32, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 101, 0, 0, 3, 18, 32,
16, 0, 1, 0, 0, 0, 104, 0, 0, 2, 1, 0, 0, 0, 54, 0, 0, 5, 18,
0, 16, 0, 0, 0, 0, 0, 10, 16, 16, 0, 0, 0, 0, 0, 54, 0, 0, 6,
50, 32, 16, 0, 0, 0, 0, 0, 70, 144, 144, 0, 10, 0, 16, 0, 0, 0, 0,
0, 54, 0, 0, 8, 194, 32, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 54, 0, 0, 5, 18,
32, 16, 0, 1, 0, 0, 0, 10, 16, 16, 0, 1, 0, 0, 0, 62, 0, 0, 1,
83, 84, 65, 84, 116, 0, 0, 0, 5, 0, 0, 0, 1, 0, 0, 0, 6, 0, 0,
0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
...@@ -5,7 +5,7 @@ REM Use of this source code is governed by a BSD-style license that can be ...@@ -5,7 +5,7 @@ REM Use of this source code is governed by a BSD-style license that can be
REM found in the LICENSE file. REM found in the LICENSE file.
REM REM
PATH %PATH%;%ProgramFiles(x86)%\Windows Kits\8.1\bin\x86;%DXSDK_DIR%\Utilities\bin\x86 PATH %ProgramFiles(x86)%\Windows Kits\8.1\bin\x86;%DXSDK_DIR%\Utilities\bin\x86;%PATH%
setlocal setlocal
set errorCount=0 set errorCount=0
...@@ -49,6 +49,8 @@ call:BuildShader Clear11.hlsl VS_Clear_FL9 vs_4_0_level_9_ ...@@ -49,6 +49,8 @@ call:BuildShader Clear11.hlsl VS_Clear_FL9 vs_4_0_level_9_
call:BuildShader Clear11.hlsl PS_ClearFloat_FL9 ps_4_0_level_9_3 compiled\clearfloat11_fl9ps.h %debug% call:BuildShader Clear11.hlsl PS_ClearFloat_FL9 ps_4_0_level_9_3 compiled\clearfloat11_fl9ps.h %debug%
call:BuildShader Clear11.hlsl VS_Clear vs_4_0 compiled\clear11vs.h %debug% call:BuildShader Clear11.hlsl VS_Clear vs_4_0 compiled\clear11vs.h %debug%
call:BuildShader Clear11.hlsl VS_Multiview_Clear vs_4_0 compiled\clear11multiviewvs.h %debug%
call:BuildShader Clear11.hlsl GS_Multiview_Clear gs_4_0 compiled\clear11multiviewgs.h %debug%
call:BuildShader Clear11.hlsl PS_ClearDepth ps_4_0 compiled\cleardepth11ps.h %debug% call:BuildShader Clear11.hlsl PS_ClearDepth ps_4_0 compiled\cleardepth11ps.h %debug%
call:BuildShader Clear11.hlsl PS_ClearFloat1 ps_4_0 compiled\clearfloat11ps1.h %debug% call:BuildShader Clear11.hlsl PS_ClearFloat1 ps_4_0 compiled\clearfloat11ps1.h %debug%
call:BuildShader Clear11.hlsl PS_ClearFloat2 ps_4_0 compiled\clearfloat11ps2.h %debug% call:BuildShader Clear11.hlsl PS_ClearFloat2 ps_4_0 compiled\clearfloat11ps2.h %debug%
......
...@@ -1224,6 +1224,76 @@ TEST_P(FramebufferMultiviewLayeredClearTest, ScissoredClear) ...@@ -1224,6 +1224,76 @@ TEST_P(FramebufferMultiviewLayeredClearTest, ScissoredClear)
EXPECT_EQ(GLColor::red, getLayerColor(3, GL_COLOR_ATTACHMENT0, 1, 0)); EXPECT_EQ(GLColor::red, getLayerColor(3, GL_COLOR_ATTACHMENT0, 1, 0));
} }
// Test that glClearBufferfi clears the contents of the stencil buffer for only the attached layers
// to a layered FBO.
TEST_P(FramebufferMultiviewLayeredClearTest, ScissoredClearBufferfi)
{
if (!requestMultiviewExtension())
{
return;
}
// Create program to draw a quad.
const std::string &vs =
"#version 300 es\n"
"in vec3 vPos;\n"
"void main(){\n"
" gl_Position = vec4(vPos, 1.);\n"
"}\n";
const std::string &fs =
"#version 300 es\n"
"precision mediump float;\n"
"uniform vec3 uCol;\n"
"out vec4 col;\n"
"void main(){\n"
" col = vec4(uCol,1.);\n"
"}\n";
ANGLE_GL_PROGRAM(program, vs, fs);
glUseProgram(program);
GLuint mColorUniformLoc = glGetUniformLocation(program, "uCol");
initializeFBOs(1, 2, 4, 1, 2, 1, true, false);
glEnable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST);
// Set clear values.
glClearColor(1, 0, 0, 1);
glClearStencil(0xFF);
// Clear the color and stencil buffers of each layer.
for (size_t i = 0u; i < mNonMultiviewFBO.size(); ++i)
{
glBindFramebuffer(GL_FRAMEBUFFER, mNonMultiviewFBO[i]);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
// Switch to multiview framebuffer and clear portions of the texture.
glBindFramebuffer(GL_FRAMEBUFFER, mMultiviewFBO);
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, 1, 1);
glClearBufferfi(GL_DEPTH_STENCIL, 0, 0.0f, 0);
glDisable(GL_SCISSOR_TEST);
// Draw a fullscreen quad, but adjust the stencil function so that only the cleared regions pass
// the test.
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glStencilFunc(GL_EQUAL, 0x00, 0xFF);
for (size_t i = 0u; i < mNonMultiviewFBO.size(); ++i)
{
glBindFramebuffer(GL_FRAMEBUFFER, mNonMultiviewFBO[i]);
glUniform3f(mColorUniformLoc, 0.0f, 1.0f, 0.0f);
drawQuad(program, "vPos", 0.0f, 1.0f, true);
}
EXPECT_EQ(GLColor::red, getLayerColor(0, GL_COLOR_ATTACHMENT0, 0, 0));
EXPECT_EQ(GLColor::red, getLayerColor(0, GL_COLOR_ATTACHMENT0, 0, 1));
EXPECT_EQ(GLColor::green, getLayerColor(1, GL_COLOR_ATTACHMENT0, 0, 0));
EXPECT_EQ(GLColor::red, getLayerColor(1, GL_COLOR_ATTACHMENT0, 0, 1));
EXPECT_EQ(GLColor::green, getLayerColor(2, GL_COLOR_ATTACHMENT0, 0, 0));
EXPECT_EQ(GLColor::red, getLayerColor(2, GL_COLOR_ATTACHMENT0, 0, 1));
EXPECT_EQ(GLColor::red, getLayerColor(3, GL_COLOR_ATTACHMENT0, 0, 0));
EXPECT_EQ(GLColor::red, getLayerColor(3, GL_COLOR_ATTACHMENT0, 0, 1));
}
ANGLE_INSTANTIATE_TEST(FramebufferMultiviewTest, ES3_OPENGL()); ANGLE_INSTANTIATE_TEST(FramebufferMultiviewTest, ES3_OPENGL());
ANGLE_INSTANTIATE_TEST(FramebufferMultiviewSideBySideClearTest, ES3_OPENGL(), ES3_D3D11()); ANGLE_INSTANTIATE_TEST(FramebufferMultiviewSideBySideClearTest, ES3_OPENGL(), ES3_D3D11());
ANGLE_INSTANTIATE_TEST(FramebufferMultiviewLayeredClearTest, ES3_OPENGL()); ANGLE_INSTANTIATE_TEST(FramebufferMultiviewLayeredClearTest, ES3_OPENGL(), ES3_D3D11());
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment