Commit 8cf4a39b by Jamie Madill

Return a ref for FBO attachment image indexes.

This cleans up the syntax somewhat. Also place some more of the helper methods in the header. BUG=angleproject:963 Change-Id: I62419095a7b65486f54d74791027594e8e595e48 Reviewed-on: https://chromium-review.googlesource.com/263629Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 7936a6d3
...@@ -612,7 +612,7 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach ...@@ -612,7 +612,7 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach
if (attachmentObj->type() == GL_TEXTURE) if (attachmentObj->type() == GL_TEXTURE)
{ {
mData.mStencilAttachment = new TextureAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getTexture(), mData.mStencilAttachment = new TextureAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getTexture(),
*attachmentObj->getTextureImageIndex()); attachmentObj->getTextureImageIndex());
mImpl->setStencilAttachment(mData.mStencilAttachment); mImpl->setStencilAttachment(mData.mStencilAttachment);
} }
else if (attachmentObj->type() == GL_RENDERBUFFER) else if (attachmentObj->type() == GL_RENDERBUFFER)
......
...@@ -76,15 +76,10 @@ GLenum FramebufferAttachment::getColorEncoding() const ...@@ -76,15 +76,10 @@ GLenum FramebufferAttachment::getColorEncoding() const
return GetInternalFormatInfo(getInternalFormat()).colorEncoding; return GetInternalFormatInfo(getInternalFormat()).colorEncoding;
} }
GLuint FramebufferAttachment::id() const const ImageIndex &FramebufferAttachment::getTextureImageIndex() const
{
return mResource->id();
}
const ImageIndex *FramebufferAttachment::getTextureImageIndex() const
{ {
ASSERT(type() == GL_TEXTURE); ASSERT(type() == GL_TEXTURE);
return &mTextureIndex; return mTextureIndex;
} }
GLenum FramebufferAttachment::cubeMapFace() const GLenum FramebufferAttachment::cubeMapFace() const
......
...@@ -48,11 +48,10 @@ class FramebufferAttachment : angle::NonCopyable ...@@ -48,11 +48,10 @@ class FramebufferAttachment : angle::NonCopyable
bool isRenderbufferWithId(GLuint renderbufferId) const { return type() == GL_RENDERBUFFER && id() == renderbufferId; } bool isRenderbufferWithId(GLuint renderbufferId) const { return type() == GL_RENDERBUFFER && id() == renderbufferId; }
GLenum getBinding() const { return mBinding; } GLenum getBinding() const { return mBinding; }
GLuint id() const { return mResource.id(); }
GLuint id() const;
// These methods are only legal to call on Texture attachments // These methods are only legal to call on Texture attachments
const ImageIndex *getTextureImageIndex() const; const ImageIndex &getTextureImageIndex() const;
GLenum cubeMapFace() const; GLenum cubeMapFace() const;
GLint mipLevel() const; GLint mipLevel() const;
GLint layer() const; GLint layer() const;
......
...@@ -380,9 +380,8 @@ gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, ...@@ -380,9 +380,8 @@ gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment,
gl::Texture *texture = attachment->getTexture(); gl::Texture *texture = attachment->getTexture();
ASSERT(texture); ASSERT(texture);
TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture); TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture);
const gl::ImageIndex *index = attachment->getTextureImageIndex(); const gl::ImageIndex &index = attachment->getTextureImageIndex();
ASSERT(index); return textureD3D->getRenderTarget(index, outRT);
return textureD3D->getRenderTarget(*index, outRT);
} }
else if (attachment->type() == GL_RENDERBUFFER) else if (attachment->type() == GL_RENDERBUFFER)
{ {
...@@ -425,9 +424,8 @@ unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment) ...@@ -425,9 +424,8 @@ unsigned int GetAttachmentSerial(const gl::FramebufferAttachment *attachment)
gl::Texture *texture = attachment->getTexture(); gl::Texture *texture = attachment->getTexture();
ASSERT(texture); ASSERT(texture);
TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture); TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture);
const gl::ImageIndex *index = attachment->getTextureImageIndex(); const gl::ImageIndex &index = attachment->getTextureImageIndex();
ASSERT(index); return textureD3D->getRenderTargetSerial(index);
return textureD3D->getRenderTargetSerial(*index);
} }
else if (attachment->type() == GL_RENDERBUFFER) else if (attachment->type() == GL_RENDERBUFFER)
{ {
......
...@@ -76,11 +76,11 @@ enum ...@@ -76,11 +76,11 @@ enum
// dirtyPointer is a special value that will make the comparison with any valid pointer fail and force the renderer to re-apply the state. // dirtyPointer is a special value that will make the comparison with any valid pointer fail and force the renderer to re-apply the state.
static const uintptr_t DirtyPointer = static_cast<uintptr_t>(-1); static const uintptr_t DirtyPointer = static_cast<uintptr_t>(-1);
static bool ImageIndexConflictsWithSRV(const gl::ImageIndex *index, D3D11_SHADER_RESOURCE_VIEW_DESC desc) static bool ImageIndexConflictsWithSRV(const gl::ImageIndex &index, D3D11_SHADER_RESOURCE_VIEW_DESC desc)
{ {
unsigned mipLevel = index->mipIndex; unsigned mipLevel = index.mipIndex;
unsigned layerIndex = index->layerIndex; unsigned layerIndex = index.layerIndex;
GLenum type = index->type; GLenum type = index.type;
switch (desc.ViewDimension) switch (desc.ViewDimension)
{ {
...@@ -89,7 +89,7 @@ static bool ImageIndexConflictsWithSRV(const gl::ImageIndex *index, D3D11_SHADER ...@@ -89,7 +89,7 @@ static bool ImageIndexConflictsWithSRV(const gl::ImageIndex *index, D3D11_SHADER
unsigned maxSrvMip = desc.Texture2D.MipLevels + desc.Texture2D.MostDetailedMip; unsigned maxSrvMip = desc.Texture2D.MipLevels + desc.Texture2D.MostDetailedMip;
maxSrvMip = (desc.Texture2D.MipLevels == -1) ? INT_MAX : maxSrvMip; maxSrvMip = (desc.Texture2D.MipLevels == -1) ? INT_MAX : maxSrvMip;
unsigned mipMin = index->mipIndex; unsigned mipMin = index.mipIndex;
unsigned mipMax = (layerIndex == -1) ? INT_MAX : layerIndex; unsigned mipMax = (layerIndex == -1) ? INT_MAX : layerIndex;
return type == GL_TEXTURE_2D && RangeUI(mipMin, mipMax).intersects(RangeUI(desc.Texture2D.MostDetailedMip, maxSrvMip)); return type == GL_TEXTURE_2D && RangeUI(mipMin, mipMax).intersects(RangeUI(desc.Texture2D.MostDetailedMip, maxSrvMip));
...@@ -1184,7 +1184,7 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSi ...@@ -1184,7 +1184,7 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSi
return count >= minCount; return count >= minCount;
} }
void Renderer11::unsetConflictingSRVs(gl::SamplerType samplerType, uintptr_t resource, const gl::ImageIndex *index) void Renderer11::unsetConflictingSRVs(gl::SamplerType samplerType, uintptr_t resource, const gl::ImageIndex &index)
{ {
auto &currentSRVs = (samplerType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs); auto &currentSRVs = (samplerType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs);
...@@ -1252,8 +1252,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer) ...@@ -1252,8 +1252,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
if (colorbuffer->type() == GL_TEXTURE) if (colorbuffer->type() == GL_TEXTURE)
{ {
uintptr_t rtResource = reinterpret_cast<uintptr_t>(GetViewResource(framebufferRTVs[colorAttachment])); uintptr_t rtResource = reinterpret_cast<uintptr_t>(GetViewResource(framebufferRTVs[colorAttachment]));
const gl::ImageIndex *index = colorbuffer->getTextureImageIndex(); const gl::ImageIndex &index = colorbuffer->getTextureImageIndex();
ASSERT(index);
// The index doesn't need to be corrected for the small compressed texture workaround // The index doesn't need to be corrected for the small compressed texture workaround
// because a rendertarget is never compressed. // because a rendertarget is never compressed.
unsetConflictingSRVs(gl::SAMPLER_VERTEX, rtResource, index); unsetConflictingSRVs(gl::SAMPLER_VERTEX, rtResource, index);
...@@ -1292,8 +1291,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer) ...@@ -1292,8 +1291,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
if (depthStencil->type() == GL_TEXTURE) if (depthStencil->type() == GL_TEXTURE)
{ {
uintptr_t depthStencilResource = reinterpret_cast<uintptr_t>(GetViewResource(framebufferDSV)); uintptr_t depthStencilResource = reinterpret_cast<uintptr_t>(GetViewResource(framebufferDSV));
const gl::ImageIndex *index = depthStencil->getTextureImageIndex(); const gl::ImageIndex &index = depthStencil->getTextureImageIndex();
ASSERT(index);
// The index doesn't need to be corrected for the small compressed texture workaround // The index doesn't need to be corrected for the small compressed texture workaround
// because a rendertarget is never compressed. // because a rendertarget is never compressed.
unsetConflictingSRVs(gl::SAMPLER_VERTEX, depthStencilResource, index); unsetConflictingSRVs(gl::SAMPLER_VERTEX, depthStencilResource, index);
......
...@@ -243,7 +243,7 @@ class Renderer11 : public RendererD3D ...@@ -243,7 +243,7 @@ class Renderer11 : public RendererD3D
gl::Error drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances); gl::Error drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource); ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource);
void unsetConflictingSRVs(gl::SamplerType shaderType, uintptr_t resource, const gl::ImageIndex *index); void unsetConflictingSRVs(gl::SamplerType shaderType, uintptr_t resource, const gl::ImageIndex &index);
HMODULE mD3d11Module; HMODULE mD3d11Module;
HMODULE mDxgiModule; HMODULE mDxgiModule;
......
...@@ -573,7 +573,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -573,7 +573,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
{ {
FramebufferAttachment *readColorAttachment = readFramebuffer->getReadColorbuffer(); FramebufferAttachment *readColorAttachment = readFramebuffer->getReadColorbuffer();
if (!readColorAttachment || if (!readColorAttachment ||
(!(readColorAttachment->type() == GL_TEXTURE && readColorAttachment->getTextureImageIndex()->type == GL_TEXTURE_2D) && (!(readColorAttachment->type() == GL_TEXTURE && readColorAttachment->getTextureImageIndex().type == GL_TEXTURE_2D) &&
readColorAttachment->type() != GL_RENDERBUFFER && readColorAttachment->type() != GL_RENDERBUFFER &&
readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT)) readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT))
{ {
...@@ -588,7 +588,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -588,7 +588,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(colorAttachment); FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(colorAttachment);
ASSERT(attachment); ASSERT(attachment);
if (!(attachment->type() == GL_TEXTURE && attachment->getTextureImageIndex()->type == GL_TEXTURE_2D) && if (!(attachment->type() == GL_TEXTURE && attachment->getTextureImageIndex().type == GL_TEXTURE_2D) &&
attachment->type() != GL_RENDERBUFFER && attachment->type() != GL_RENDERBUFFER &&
attachment->type() != GL_FRAMEBUFFER_DEFAULT) attachment->type() != GL_FRAMEBUFFER_DEFAULT)
{ {
......
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