Commit d8a2258c by Geoff Lang

Remove all uses of "actual" formats.

BUG=angle:861 Change-Id: I7cd2d1a56772fdf18bcf926456399322d13e7a4f Reviewed-on: https://chromium-review.googlesource.com/236305Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 4f89e3dd
......@@ -34,42 +34,42 @@ FramebufferAttachment::~FramebufferAttachment()
GLuint FramebufferAttachment::getRedSize() const
{
return (GetInternalFormatInfo(getInternalFormat()).redBits > 0) ? GetInternalFormatInfo(getActualFormat()).redBits : 0;
return GetInternalFormatInfo(getInternalFormat()).redBits;
}
GLuint FramebufferAttachment::getGreenSize() const
{
return (GetInternalFormatInfo(getInternalFormat()).greenBits > 0) ? GetInternalFormatInfo(getActualFormat()).greenBits : 0;
return GetInternalFormatInfo(getInternalFormat()).greenBits;
}
GLuint FramebufferAttachment::getBlueSize() const
{
return (GetInternalFormatInfo(getInternalFormat()).blueBits > 0) ? GetInternalFormatInfo(getActualFormat()).blueBits : 0;
return GetInternalFormatInfo(getInternalFormat()).blueBits;
}
GLuint FramebufferAttachment::getAlphaSize() const
{
return (GetInternalFormatInfo(getInternalFormat()).alphaBits > 0) ? GetInternalFormatInfo(getActualFormat()).alphaBits : 0;
return GetInternalFormatInfo(getInternalFormat()).alphaBits;
}
GLuint FramebufferAttachment::getDepthSize() const
{
return (GetInternalFormatInfo(getInternalFormat()).depthBits > 0) ? GetInternalFormatInfo(getActualFormat()).depthBits : 0;
return GetInternalFormatInfo(getInternalFormat()).depthBits;
}
GLuint FramebufferAttachment::getStencilSize() const
{
return (GetInternalFormatInfo(getInternalFormat()).stencilBits > 0) ? GetInternalFormatInfo(getActualFormat()).stencilBits : 0;
return GetInternalFormatInfo(getInternalFormat()).stencilBits;
}
GLenum FramebufferAttachment::getComponentType() const
{
return GetInternalFormatInfo(getActualFormat()).componentType;
return GetInternalFormatInfo(getInternalFormat()).componentType;
}
GLenum FramebufferAttachment::getColorEncoding() const
{
return GetInternalFormatInfo(getActualFormat()).colorEncoding;
return GetInternalFormatInfo(getInternalFormat()).colorEncoding;
}
///// TextureAttachment Implementation ////////
......@@ -111,11 +111,6 @@ GLenum TextureAttachment::getInternalFormat() const
return mTexture->getInternalFormat(mIndex);
}
GLenum TextureAttachment::getActualFormat() const
{
return mTexture->getActualFormat(mIndex);
}
GLenum TextureAttachment::type() const
{
return GL_TEXTURE;
......@@ -181,11 +176,6 @@ GLenum RenderbufferAttachment::getInternalFormat() const
return mRenderbuffer->getInternalFormat();
}
GLenum RenderbufferAttachment::getActualFormat() const
{
return mRenderbuffer->getActualFormat();
}
GLsizei RenderbufferAttachment::getSamples() const
{
return mRenderbuffer->getSamples();
......@@ -261,11 +251,6 @@ GLenum DefaultAttachment::getInternalFormat() const
return mImpl->getInternalFormat();
}
GLenum DefaultAttachment::getActualFormat() const
{
return mImpl->getActualFormat();
}
GLsizei DefaultAttachment::getSamples() const
{
return mImpl->getSamples();
......
......@@ -57,7 +57,6 @@ class FramebufferAttachment
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLenum getActualFormat() const = 0;
virtual GLsizei getSamples() const = 0;
virtual GLuint id() const = 0;
......@@ -88,7 +87,6 @@ class TextureAttachment : public FramebufferAttachment
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
......@@ -116,7 +114,6 @@ class RenderbufferAttachment : public FramebufferAttachment
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual GLuint id() const;
......@@ -145,7 +142,6 @@ class DefaultAttachment : public FramebufferAttachment
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual GLuint id() const;
......
......@@ -25,7 +25,6 @@ Renderbuffer::Renderbuffer(rx::RenderbufferImpl *impl, GLuint id)
mWidth(0),
mHeight(0),
mInternalFormat(GL_RGBA4),
mActualFormat(GL_RGBA4),
mSamples(0)
{
ASSERT(mRenderbuffer);
......@@ -48,7 +47,6 @@ Error Renderbuffer::setStorage(GLsizei width, GLsizei height, GLenum internalfor
mHeight = height;
mInternalFormat = internalformat;
mSamples = samples;
mActualFormat = mRenderbuffer->getActualFormat();
return Error(GL_NO_ERROR);
}
......@@ -74,11 +72,6 @@ GLenum Renderbuffer::getInternalFormat() const
return mInternalFormat;
}
GLenum Renderbuffer::getActualFormat() const
{
return mActualFormat;
}
GLsizei Renderbuffer::getSamples() const
{
return mSamples;
......@@ -86,32 +79,32 @@ GLsizei Renderbuffer::getSamples() const
GLuint Renderbuffer::getRedSize() const
{
return GetInternalFormatInfo(getActualFormat()).redBits;
return GetInternalFormatInfo(mInternalFormat).redBits;
}
GLuint Renderbuffer::getGreenSize() const
{
return GetInternalFormatInfo(getActualFormat()).greenBits;
return GetInternalFormatInfo(mInternalFormat).greenBits;
}
GLuint Renderbuffer::getBlueSize() const
{
return GetInternalFormatInfo(getActualFormat()).blueBits;
return GetInternalFormatInfo(mInternalFormat).blueBits;
}
GLuint Renderbuffer::getAlphaSize() const
{
return GetInternalFormatInfo(getActualFormat()).alphaBits;
return GetInternalFormatInfo(mInternalFormat).alphaBits;
}
GLuint Renderbuffer::getDepthSize() const
{
return GetInternalFormatInfo(getActualFormat()).depthBits;
return GetInternalFormatInfo(mInternalFormat).depthBits;
}
GLuint Renderbuffer::getStencilSize() const
{
return GetInternalFormatInfo(getActualFormat()).stencilBits;
return GetInternalFormatInfo(mInternalFormat).stencilBits;
}
}
......@@ -45,7 +45,6 @@ class Renderbuffer : public RefCountObject
GLsizei getWidth() const;
GLsizei getHeight() const;
GLenum getInternalFormat() const;
GLenum getActualFormat() const;
GLsizei getSamples() const;
GLuint getRedSize() const;
GLuint getGreenSize() const;
......@@ -62,7 +61,6 @@ class Renderbuffer : public RefCountObject
GLsizei mWidth;
GLsizei mHeight;
GLenum mInternalFormat;
GLenum mActualFormat;
GLsizei mSamples;
};
......
......@@ -273,13 +273,10 @@ ClearParameters State::getClearParameters(GLbitfield mask) const
if (mask & GL_STENCIL_BUFFER_BIT)
{
if (framebufferObject->getStencilbuffer() != NULL)
if (framebufferObject->getStencilbuffer() != NULL &&
framebufferObject->getStencilbuffer()->getStencilSize() > 0)
{
GLenum stencilActualFormat = framebufferObject->getStencilbuffer()->getActualFormat();
if (GetInternalFormatInfo(stencilActualFormat).stencilBits > 0)
{
clearParams.clearStencil = true;
}
clearParams.clearStencil = true;
}
}
......
......@@ -124,12 +124,6 @@ GLenum Texture::getInternalFormat(const ImageIndex &index) const
return image->getInternalFormat();
}
GLenum Texture::getActualFormat(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index);
return image->getActualFormat();
}
Error Texture::generateMipmaps()
{
return getImplementation()->generateMipmaps();
......@@ -210,14 +204,6 @@ GLenum Texture2D::getInternalFormat(GLint level) const
return GL_NONE;
}
GLenum Texture2D::getActualFormat(GLint level) const
{
if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
return mTexture->getImage(level, 0)->getActualFormat();
else
return GL_NONE;
}
Error Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
releaseTexImage();
......@@ -455,14 +441,6 @@ GLenum TextureCubeMap::getInternalFormat(GLenum target, GLint level) const
return GL_NONE;
}
GLenum TextureCubeMap::getActualFormat(GLenum target, GLint level) const
{
if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
return mTexture->getImage(level, targetToLayerIndex(target))->getActualFormat();
else
return GL_NONE;
}
Error TextureCubeMap::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{
return mTexture->setImage(target, level, width, height, 1, internalFormat, format, type, unpack, pixels);
......@@ -700,11 +678,6 @@ GLenum Texture3D::getInternalFormat(GLint level) const
return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getInternalFormat() : GL_NONE;
}
GLenum Texture3D::getActualFormat(GLint level) const
{
return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getActualFormat() : GL_NONE;
}
bool Texture3D::isCompressed(GLint level) const
{
return GetInternalFormatInfo(getInternalFormat(level)).compressed;
......@@ -867,11 +840,6 @@ GLenum Texture2DArray::getInternalFormat(GLint level) const
return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getInternalFormat() : GL_NONE;
}
GLenum Texture2DArray::getActualFormat(GLint level) const
{
return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getActualFormat() : GL_NONE;
}
bool Texture2DArray::isCompressed(GLint level) const
{
return GetInternalFormatInfo(getInternalFormat(level)).compressed;
......
......@@ -64,7 +64,6 @@ class Texture : public RefCountObject
GLsizei getWidth(const ImageIndex &index) const;
GLsizei getHeight(const ImageIndex &index) const;
GLenum getInternalFormat(const ImageIndex &index) const;
GLenum getActualFormat(const ImageIndex &index) const;
virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const = 0;
......@@ -115,7 +114,6 @@ class Texture2D : public Texture
GLsizei getWidth(GLint level) const;
GLsizei getHeight(GLint level) const;
GLenum getInternalFormat(GLint level) const;
GLenum getActualFormat(GLint level) const;
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
......@@ -151,7 +149,6 @@ class TextureCubeMap : public Texture
GLsizei getWidth(GLenum target, GLint level) const;
GLsizei getHeight(GLenum target, GLint level) const;
GLenum getInternalFormat(GLenum target, GLint level) const;
GLenum getActualFormat(GLenum target, GLint level) const;
bool isCompressed(GLenum target, GLint level) const;
bool isDepth(GLenum target, GLint level) const;
......@@ -187,7 +184,6 @@ class Texture3D : public Texture
GLsizei getHeight(GLint level) const;
GLsizei getDepth(GLint level) const;
GLenum getInternalFormat(GLint level) const;
GLenum getActualFormat(GLint level) const;
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
......@@ -217,7 +213,6 @@ class Texture2DArray : public Texture
GLsizei getHeight(GLint level) const;
GLsizei getLayers(GLint level) const;
GLenum getInternalFormat(GLint level) const;
GLenum getActualFormat(GLint level) const;
bool isCompressed(GLint level) const;
bool isDepth(GLint level) const;
......
......@@ -32,7 +32,6 @@ class DefaultAttachmentImpl
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLenum getActualFormat() const = 0;
virtual GLsizei getSamples() const = 0;
};
......
......@@ -19,7 +19,6 @@ Image::Image()
mHeight = 0;
mDepth = 0;
mInternalFormat = GL_NONE;
mActualFormat = GL_NONE;
mTarget = GL_NONE;
mRenderable = false;
mDirty = false;
......
......@@ -39,7 +39,6 @@ class Image
GLsizei getHeight() const { return mHeight; }
GLsizei getDepth() const { return mDepth; }
GLenum getInternalFormat() const { return mInternalFormat; }
GLenum getActualFormat() const { return mActualFormat; }
GLenum getTarget() const { return mTarget; }
bool isRenderableFormat() const { return mRenderable; }
......@@ -63,7 +62,6 @@ class Image
GLsizei mHeight;
GLsizei mDepth;
GLenum mInternalFormat;
GLenum mActualFormat;
bool mRenderable;
GLenum mTarget;
......
......@@ -25,20 +25,12 @@ class RenderTarget
virtual GLsizei getHeight() const = 0;
virtual GLsizei getDepth() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLenum getActualFormat() const = 0;
virtual GLsizei getSamples() const = 0;
gl::Extents getExtents() const { return gl::Extents(getWidth(), getHeight(), getDepth()); }
virtual unsigned int getSerial() const;
static unsigned int issueSerials(unsigned int count);
struct Desc {
GLsizei width;
GLsizei height;
GLsizei depth;
GLenum format;
};
private:
DISALLOW_COPY_AND_ASSIGN(RenderTarget);
......
......@@ -26,8 +26,6 @@ class RenderbufferImpl
virtual gl::Error setStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples) = 0;
virtual GLenum getActualFormat() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferImpl);
};
......
......@@ -50,11 +50,6 @@ GLenum DefaultAttachmentD3D::getInternalFormat() const
return mRenderTarget->getInternalFormat();
}
GLenum DefaultAttachmentD3D::getActualFormat() const
{
return mRenderTarget->getActualFormat();
}
GLsizei DefaultAttachmentD3D::getSamples() const
{
return mRenderTarget->getSamples();
......@@ -222,10 +217,17 @@ GLenum FramebufferD3D::getImplementationColorReadFormat() const
return GL_NONE;
}
GLenum actualFormat = mColorBuffers[0]->getActualFormat();
const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(actualFormat);
RenderTarget *attachmentRenderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(mColorBuffers[0], &attachmentRenderTarget);
if (error.isError())
{
return GL_NONE;
}
return actualFormatInfo.format;
GLenum implementationFormat = getRenderTargetImplementationFormat(attachmentRenderTarget);
const gl::InternalFormat &implementationFormatInfo = gl::GetInternalFormatInfo(implementationFormat);
return implementationFormatInfo.format;
}
GLenum FramebufferD3D::getImplementationColorReadType() const
......@@ -238,10 +240,17 @@ GLenum FramebufferD3D::getImplementationColorReadType() const
return GL_NONE;
}
GLenum actualFormat = mColorBuffers[0]->getActualFormat();
const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(actualFormat);
RenderTarget *attachmentRenderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(mColorBuffers[0], &attachmentRenderTarget);
if (error.isError())
{
return GL_NONE;
}
GLenum implementationFormat = getRenderTargetImplementationFormat(attachmentRenderTarget);
const gl::InternalFormat &implementationFormatInfo = gl::GetInternalFormatInfo(implementationFormat);
return actualFormatInfo.type;
return implementationFormatInfo.type;
}
gl::Error FramebufferD3D::readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const
......
......@@ -37,7 +37,6 @@ class DefaultAttachmentD3D : public DefaultAttachmentImpl
virtual GLsizei getWidth() const override;
virtual GLsizei getHeight() const override;
virtual GLenum getInternalFormat() const override;
virtual GLenum getActualFormat() const override;
virtual GLsizei getSamples() const override;
RenderTarget *getRenderTarget() const;
......@@ -97,6 +96,8 @@ class FramebufferD3D : public FramebufferImpl
virtual gl::Error blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor,
bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter,
const gl::Framebuffer *sourceFramebuffer) = 0;
virtual GLenum getRenderTargetImplementationFormat(RenderTarget *renderTarget) const = 0;
};
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTarget **outRT);
......
......@@ -55,11 +55,6 @@ gl::Error RenderbufferD3D::setStorage(GLsizei width, GLsizei height, GLenum inte
return gl::Error(GL_NO_ERROR);
}
GLenum RenderbufferD3D::getActualFormat() const
{
return (mRenderTarget ? mRenderTarget->getActualFormat() : GL_RGBA4);
}
RenderTarget *RenderbufferD3D::getRenderTarget()
{
return mRenderTarget;
......
......@@ -30,8 +30,6 @@ class RenderbufferD3D : public RenderbufferImpl
virtual gl::Error setStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples) override;
virtual GLenum getActualFormat() const;
RenderTarget *getRenderTarget();
unsigned int getRenderTargetSerial() const;
......
......@@ -577,14 +577,6 @@ GLenum TextureD3D_2D::getInternalFormat(GLint level) const
return GL_NONE;
}
GLenum TextureD3D_2D::getActualFormat(GLint level) const
{
if (level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
return mImageArray[level]->getActualFormat();
else
return GL_NONE;
}
bool TextureD3D_2D::isDepth(GLint level) const
{
return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
......
......@@ -119,7 +119,6 @@ class TextureD3D_2D : public TextureD3D
GLsizei getWidth(GLint level) const;
GLsizei getHeight(GLint level) const;
GLenum getInternalFormat(GLint level) const;
GLenum getActualFormat(GLint level) const;
bool isDepth(GLint level) const;
virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
......
......@@ -10,6 +10,7 @@
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
......@@ -302,16 +303,16 @@ gl::Error Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, cons
return gl::Error(GL_OUT_OF_MEMORY, "Internal render target view pointer unexpectedly null.");
}
const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(attachment->getActualFormat());
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(renderTarget->getDXGIFormat());
// Check if the actual format has a channel that the internal format does not and set them to the
// default values
const float clearValues[4] =
{
((formatInfo.redBits == 0 && actualFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red),
((formatInfo.greenBits == 0 && actualFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green),
((formatInfo.blueBits == 0 && actualFormatInfo.blueBits > 0) ? 0.0f : clearParams.colorFClearValue.blue),
((formatInfo.alphaBits == 0 && actualFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha),
((formatInfo.redBits == 0 && dxgiFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red),
((formatInfo.greenBits == 0 && dxgiFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green),
((formatInfo.blueBits == 0 && dxgiFormatInfo.blueBits > 0) ? 0.0f : clearParams.colorFClearValue.blue),
((formatInfo.alphaBits == 0 && dxgiFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha),
};
if (needScissoredClear)
......@@ -347,9 +348,9 @@ gl::Error Clear11::clearFramebuffer(const gl::ClearParameters &clearParams, cons
return error;
}
const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(attachment->getActualFormat());
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(renderTarget->getDXGIFormat());
unsigned int stencilUnmasked = (stencilAttachment != nullptr) ? (1 << actualFormatInfo.stencilBits) - 1 : 0;
unsigned int stencilUnmasked = (stencilAttachment != nullptr) ? (1 << dxgiFormatInfo.stencilBits) - 1 : 0;
bool needMaskedStencilClear = clearParams.clearStencil && (clearParams.stencilWriteMask & stencilUnmasked) != stencilUnmasked;
if (needScissoredClear || needMaskedStencilClear)
......
......@@ -13,6 +13,7 @@
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
......@@ -225,4 +226,11 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
return gl::Error(GL_NO_ERROR);
}
GLenum Framebuffer11::getRenderTargetImplementationFormat(RenderTarget *renderTarget) const
{
RenderTarget11 *renderTarget11 = RenderTarget11::makeRenderTarget11(renderTarget);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(renderTarget11->getDXGIFormat());
return dxgiFormatInfo.internalFormat;
}
}
......@@ -34,6 +34,9 @@ class Framebuffer11 : public FramebufferD3D
bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter,
const gl::Framebuffer *sourceFramebuffer) override;
GLenum getRenderTargetImplementationFormat(RenderTarget *renderTarget) const override;
Renderer11 *const mRenderer;
};
......
......@@ -222,9 +222,7 @@ bool Image11::redefine(GLenum target, GLenum internalformat, GLsizei width, GLsi
// compute the d3d format that will be used
const d3d11::TextureFormat &formatInfo = d3d11::GetTextureFormatInfo(internalformat, mFeatureLevel);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(formatInfo.texFormat);
mDXGIFormat = formatInfo.texFormat;
mActualFormat = dxgiFormatInfo.internalFormat;
mRenderable = (formatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN);
releaseStagingTexture();
......@@ -438,7 +436,8 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R
}
// determine the offset coordinate into the destination buffer
GLsizei rowOffset = gl::GetInternalFormatInfo(mActualFormat).pixelBytes * xoffset;
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
GLsizei rowOffset = dxgiFormatInfo.pixelBytes * xoffset;
uint8_t *dataOffset = static_cast<uint8_t*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch;
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
......
......@@ -188,7 +188,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ID3D11
mHeight(height),
mDepth(depth),
mInternalFormat(internalFormat),
mActualFormat(internalFormat),
mDXGIFormat(DXGI_FORMAT_UNKNOWN),
mSamples(samples),
mSubresourceIndex(0),
mTexture(resource),
......@@ -217,9 +217,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ID3D11
D3D11_RENDER_TARGET_VIEW_DESC desc;
mRenderTarget->GetDesc(&desc);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(desc.Format);
mActualFormat = dxgiFormatInfo.internalFormat;
mDXGIFormat = desc.Format;
}
}
......@@ -229,7 +227,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ID3D11
mHeight(height),
mDepth(depth),
mInternalFormat(internalFormat),
mActualFormat(internalFormat),
mDXGIFormat(DXGI_FORMAT_UNKNOWN),
mSamples(samples),
mSubresourceIndex(0),
mTexture(resource),
......@@ -258,9 +256,7 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ID3D11
D3D11_DEPTH_STENCIL_VIEW_DESC desc;
mDepthStencil->GetDesc(&desc);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(desc.Format);
mActualFormat = dxgiFormatInfo.internalFormat;
mDXGIFormat = desc.Format;
}
}
......@@ -312,11 +308,6 @@ GLenum TextureRenderTarget11::getInternalFormat() const
return mInternalFormat;
}
GLenum TextureRenderTarget11::getActualFormat() const
{
return mActualFormat;
}
GLsizei TextureRenderTarget11::getSamples() const
{
return mSamples;
......@@ -327,6 +318,10 @@ unsigned int TextureRenderTarget11::getSubresourceIndex() const
return mSubresourceIndex;
}
DXGI_FORMAT TextureRenderTarget11::getDXGIFormat() const
{
return mDXGIFormat;
}
SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain, Renderer11 *renderer, bool depth)
: mSwapChain(swapChain),
......@@ -360,11 +355,6 @@ GLenum SurfaceRenderTarget11::getInternalFormat() const
return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetBackBufferInternalFormat());
}
GLenum SurfaceRenderTarget11::getActualFormat() const
{
return d3d11::GetDXGIFormatInfo(d3d11::GetTextureFormatInfo(getInternalFormat(), mRenderer->getFeatureLevel()).texFormat).internalFormat;
}
GLsizei SurfaceRenderTarget11::getSamples() const
{
// Our EGL surfaces do not support multisampling.
......@@ -396,4 +386,9 @@ unsigned int SurfaceRenderTarget11::getSubresourceIndex() const
return 0;
}
DXGI_FORMAT SurfaceRenderTarget11::getDXGIFormat() const
{
return d3d11::GetTextureFormatInfo(getInternalFormat(), mRenderer->getFeatureLevel()).texFormat;
}
}
......@@ -32,6 +32,8 @@ class RenderTarget11 : public RenderTarget
virtual unsigned int getSubresourceIndex() const = 0;
virtual DXGI_FORMAT getDXGIFormat() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(RenderTarget11);
D3D_FEATURE_LEVEL mFeatureLevel;
......@@ -51,7 +53,6 @@ class TextureRenderTarget11 : public RenderTarget11
GLsizei getHeight() const override;
GLsizei getDepth() const override;
GLenum getInternalFormat() const override;
GLenum getActualFormat() const override;
GLsizei getSamples() const override;
ID3D11Resource *getTexture() const override;
......@@ -61,6 +62,8 @@ class TextureRenderTarget11 : public RenderTarget11
unsigned int getSubresourceIndex() const override;
DXGI_FORMAT getDXGIFormat() const override;
private:
DISALLOW_COPY_AND_ASSIGN(TextureRenderTarget11);
......@@ -68,7 +71,7 @@ class TextureRenderTarget11 : public RenderTarget11
GLsizei mHeight;
GLsizei mDepth;
GLenum mInternalFormat;
GLenum mActualFormat;
DXGI_FORMAT mDXGIFormat;
GLsizei mSamples;
unsigned int mSubresourceIndex;
......@@ -88,7 +91,6 @@ class SurfaceRenderTarget11 : public RenderTarget11
GLsizei getHeight() const override;
GLsizei getDepth() const override;
GLenum getInternalFormat() const override;
GLenum getActualFormat() const override;
GLsizei getSamples() const override;
ID3D11Resource *getTexture() const override;
......@@ -98,6 +100,8 @@ class SurfaceRenderTarget11 : public RenderTarget11
unsigned int getSubresourceIndex() const override;
DXGI_FORMAT getDXGIFormat() const override;
private:
DISALLOW_COPY_AND_ASSIGN(SurfaceRenderTarget11);
......
......@@ -995,7 +995,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
// Also extract the render target dimensions and view
unsigned int renderTargetWidth = 0;
unsigned int renderTargetHeight = 0;
GLenum renderTargetFormat = 0;
DXGI_FORMAT renderTargetFormat = DXGI_FORMAT_UNKNOWN;
unsigned int renderTargetSerials[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS] = {0};
ID3D11RenderTargetView* framebufferRTVs[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS] = {NULL};
bool missingColorRenderTarget = true;
......@@ -1034,9 +1034,9 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
if (missingColorRenderTarget)
{
renderTargetWidth = colorbuffer->getWidth();
renderTargetHeight = colorbuffer->getHeight();
renderTargetFormat = colorbuffer->getActualFormat();
renderTargetWidth = renderTarget->getWidth();
renderTargetHeight = renderTarget->getHeight();
renderTargetFormat = renderTarget->getDXGIFormat();
missingColorRenderTarget = false;
}
......@@ -1088,9 +1088,9 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
// the depth stencil
if (missingColorRenderTarget)
{
renderTargetWidth = depthStencil->getWidth();
renderTargetHeight = depthStencil->getHeight();
renderTargetFormat = depthStencil->getActualFormat();
renderTargetWidth = depthStencilRenderTarget->getWidth();
renderTargetHeight = depthStencilRenderTarget->getHeight();
renderTargetFormat = depthStencilRenderTarget->getDXGIFormat();
}
}
......@@ -3098,12 +3098,12 @@ gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const
drawRect.x < 0 || drawRect.x + drawRect.width > drawSize.width ||
drawRect.y < 0 || drawRect.y + drawRect.height > drawSize.height;
const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(drawRenderTarget->getActualFormat());
bool partialDSBlit = (actualFormatInfo.depthBits > 0 && depthBlit) != (actualFormatInfo.stencilBits > 0 && stencilBlit);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(drawRenderTarget11->getDXGIFormat());
bool partialDSBlit = (dxgiFormatInfo.depthBits > 0 && depthBlit) != (dxgiFormatInfo.stencilBits > 0 && stencilBlit);
gl::Error result(GL_NO_ERROR);
if (readRenderTarget11->getActualFormat() == drawRenderTarget->getActualFormat() &&
if (readRenderTarget11->getDXGIFormat() == drawRenderTarget11->getDXGIFormat() &&
!stretchRequired && !outOfBounds && !flipRequired && !partialDSBlit &&
(!(depthBlit || stencilBlit) || wholeBufferCopy))
{
......
......@@ -249,7 +249,14 @@ class Renderer11 : public RendererD3D
unsigned int mAppliedStencilbufferSerial;
bool mDepthStencilInitialized;
bool mRenderTargetDescInitialized;
RenderTarget::Desc mRenderTargetDesc;
struct RenderTargetDesc
{
size_t width;
size_t height;
DXGI_FORMAT format;
};
RenderTargetDesc mRenderTargetDesc;
// Currently applied sampler states
std::vector<bool> mForceSetVertexSamplerStates;
......
......@@ -410,4 +410,11 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
return gl::Error(GL_NO_ERROR);
}
GLenum Framebuffer9::getRenderTargetImplementationFormat(RenderTarget *renderTarget) const
{
RenderTarget9 *renderTarget9 = RenderTarget9::makeRenderTarget9(renderTarget);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(renderTarget9->getD3DFormat());
return d3dFormatInfo.internalFormat;
}
}
......@@ -31,6 +31,8 @@ class Framebuffer9 : public FramebufferD3D
bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter,
const gl::Framebuffer *sourceFramebuffer) override;
GLenum getRenderTargetImplementationFormat(RenderTarget *renderTarget) const override;
Renderer9 *const mRenderer;
};
......
......@@ -190,9 +190,7 @@ bool Image9::redefine(GLenum target, GLenum internalformat, GLsizei width, GLsiz
// compute the d3d format that will be used
const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(internalformat);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat);
mD3DFormat = d3d9FormatInfo.texFormat;
mActualFormat = d3dFormatInfo.internalFormat;
mRenderable = (d3d9FormatInfo.renderFormat != D3DFMT_UNKNOWN);
SafeRelease(mSurface);
......
......@@ -29,7 +29,7 @@ TextureRenderTarget9::TextureRenderTarget9(IDirect3DSurface9 *surface, GLenum in
mHeight(height),
mDepth(depth),
mInternalFormat(internalFormat),
mActualFormat(internalFormat),
mD3DFormat(D3DFMT_UNKNOWN),
mSamples(samples),
mRenderTarget(surface)
{
......@@ -39,9 +39,7 @@ TextureRenderTarget9::TextureRenderTarget9(IDirect3DSurface9 *surface, GLenum in
{
D3DSURFACE_DESC description;
mRenderTarget->GetDesc(&description);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(description.Format);
mActualFormat = d3dFormatInfo.internalFormat;
mD3DFormat = description.Format;
}
}
......@@ -70,11 +68,6 @@ GLenum TextureRenderTarget9::getInternalFormat() const
return mInternalFormat;
}
GLenum TextureRenderTarget9::getActualFormat() const
{
return mActualFormat;
}
GLsizei TextureRenderTarget9::getSamples() const
{
return mSamples;
......@@ -92,6 +85,10 @@ IDirect3DSurface9 *TextureRenderTarget9::getSurface()
return mRenderTarget;
}
D3DFORMAT TextureRenderTarget9::getD3DFormat() const
{
return mD3DFormat;
}
SurfaceRenderTarget9::SurfaceRenderTarget9(SwapChain9 *swapChain, bool depth)
: mSwapChain(swapChain),
......@@ -123,11 +120,6 @@ GLenum SurfaceRenderTarget9::getInternalFormat() const
return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetBackBufferInternalFormat());
}
GLenum SurfaceRenderTarget9::getActualFormat() const
{
return d3d9::GetD3DFormatInfo(d3d9::GetTextureFormatInfo(getInternalFormat()).texFormat).internalFormat;
}
GLsizei SurfaceRenderTarget9::getSamples() const
{
// Our EGL surfaces do not support multisampling.
......@@ -139,4 +131,9 @@ IDirect3DSurface9 *SurfaceRenderTarget9::getSurface()
return (mDepth ? mSwapChain->getDepthStencil() : mSwapChain->getRenderTarget());
}
D3DFORMAT SurfaceRenderTarget9::getD3DFormat() const
{
return d3d9::GetTextureFormatInfo(getInternalFormat()).texFormat;
}
}
......@@ -27,6 +27,8 @@ class RenderTarget9 : public RenderTarget
virtual IDirect3DSurface9 *getSurface() = 0;
virtual D3DFORMAT getD3DFormat() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(RenderTarget9);
};
......@@ -42,11 +44,12 @@ class TextureRenderTarget9 : public RenderTarget9
GLsizei getHeight() const override;
GLsizei getDepth() const override;
GLenum getInternalFormat() const override;
GLenum getActualFormat() const override;
GLsizei getSamples() const override;
IDirect3DSurface9 *getSurface() override;
D3DFORMAT getD3DFormat() const override;
private:
DISALLOW_COPY_AND_ASSIGN(TextureRenderTarget9);
......@@ -54,7 +57,7 @@ class TextureRenderTarget9 : public RenderTarget9
GLsizei mHeight;
GLsizei mDepth;
GLenum mInternalFormat;
GLenum mActualFormat;
D3DFORMAT mD3DFormat;
GLsizei mSamples;
IDirect3DSurface9 *mRenderTarget;
......@@ -70,11 +73,12 @@ class SurfaceRenderTarget9 : public RenderTarget9
GLsizei getHeight() const override;
GLsizei getDepth() const override;
GLenum getInternalFormat() const override;
GLenum getActualFormat() const override;
GLsizei getSamples() const override;
IDirect3DSurface9 *getSurface() override;
D3DFORMAT getD3DFormat() const override;
private:
DISALLOW_COPY_AND_ASSIGN(SurfaceRenderTarget9);
......
......@@ -1219,6 +1219,10 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
}
ASSERT(colorBuffer);
size_t renderTargetWidth = 0;
size_t renderTargetHeight = 0;
D3DFORMAT renderTargetFormat = D3DFMT_UNKNOWN;
bool renderTargetChanged = false;
unsigned int renderTargetSerial = GetAttachmentSerial(colorBuffer);
if (renderTargetSerial != mAppliedRenderTargetSerial)
......@@ -1238,6 +1242,10 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
mDevice->SetRenderTarget(0, renderTargetSurface);
SafeRelease(renderTargetSurface);
renderTargetWidth = renderTarget->getWidth();
renderTargetHeight = renderTarget->getHeight();
renderTargetFormat = renderTarget->getD3DFormat();
mAppliedRenderTargetSerial = renderTargetSerial;
renderTargetChanged = true;
}
......@@ -1295,9 +1303,9 @@ gl::Error Renderer9::applyRenderTarget(const gl::FramebufferAttachment *colorBuf
mForceSetViewport = true;
mForceSetBlendState = true;
mRenderTargetDesc.width = colorBuffer->getWidth();
mRenderTargetDesc.height = colorBuffer->getHeight();
mRenderTargetDesc.format = colorBuffer->getActualFormat();
mRenderTargetDesc.width = renderTargetWidth;
mRenderTargetDesc.height = renderTargetHeight;
mRenderTargetDesc.format = renderTargetFormat;
mRenderTargetDescInitialized = true;
}
......@@ -1896,8 +1904,18 @@ gl::Error Renderer9::clear(const gl::ClearParameters &clearParams, const gl::Fra
unsigned int stencilUnmasked = 0x0;
if (clearParams.clearStencil && depthStencilBuffer->getStencilSize() > 0)
{
unsigned int stencilSize = gl::GetInternalFormatInfo((depthStencilBuffer->getActualFormat())).stencilBits;
stencilUnmasked = (0x1 << stencilSize) - 1;
RenderTarget *stencilRenderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(depthStencilBuffer, &stencilRenderTarget);
if (error.isError())
{
return error;
}
RenderTarget9 *stencilRenderTarget9 = RenderTarget9::makeRenderTarget9(stencilRenderTarget);
ASSERT(stencilRenderTarget9);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(stencilRenderTarget9->getD3DFormat());
stencilUnmasked = (0x1 << d3dFormatInfo.stencilBits) - 1;
}
const bool needMaskedStencilClear = clearParams.clearStencil &&
......@@ -1907,13 +1925,23 @@ gl::Error Renderer9::clear(const gl::ClearParameters &clearParams, const gl::Fra
D3DCOLOR color = D3DCOLOR_ARGB(255, 0, 0, 0);
if (clearColor)
{
RenderTarget *colorRenderTarget = NULL;
gl::Error error = GetAttachmentRenderTarget(colorBuffer, &colorRenderTarget);
if (error.isError())
{
return error;
}
RenderTarget9 *colorRenderTarget9 = RenderTarget9::makeRenderTarget9(colorRenderTarget);
ASSERT(colorRenderTarget9);
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(colorBuffer->getInternalFormat());
const gl::InternalFormat &actualFormatInfo = gl::GetInternalFormatInfo(colorBuffer->getActualFormat());
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(colorRenderTarget9->getD3DFormat());
color = D3DCOLOR_ARGB(gl::unorm<8>((formatInfo.alphaBits == 0 && actualFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha),
gl::unorm<8>((formatInfo.redBits == 0 && actualFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red),
gl::unorm<8>((formatInfo.greenBits == 0 && actualFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green),
gl::unorm<8>((formatInfo.blueBits == 0 && actualFormatInfo.blueBits > 0) ? 0.0f : clearParams.colorFClearValue.blue));
color = D3DCOLOR_ARGB(gl::unorm<8>((formatInfo.alphaBits == 0 && d3dFormatInfo.alphaBits > 0) ? 1.0f : clearParams.colorFClearValue.alpha),
gl::unorm<8>((formatInfo.redBits == 0 && d3dFormatInfo.redBits > 0) ? 0.0f : clearParams.colorFClearValue.red),
gl::unorm<8>((formatInfo.greenBits == 0 && d3dFormatInfo.greenBits > 0) ? 0.0f : clearParams.colorFClearValue.green),
gl::unorm<8>((formatInfo.blueBits == 0 && d3dFormatInfo.blueBits > 0) ? 0.0f : clearParams.colorFClearValue.blue));
if ((formatInfo.redBits > 0 && !clearParams.colorMaskRed) ||
(formatInfo.greenBits > 0 && !clearParams.colorMaskGreen) ||
......
......@@ -268,10 +268,17 @@ class Renderer9 : public RendererD3D
unsigned int mAppliedDepthStencilSerial;
bool mDepthStencilInitialized;
bool mRenderTargetDescInitialized;
RenderTarget::Desc mRenderTargetDesc;
unsigned int mCurStencilSize;
unsigned int mCurDepthSize;
struct RenderTargetDesc
{
size_t width;
size_t height;
D3DFORMAT format;
};
RenderTargetDesc mRenderTargetDesc;
IDirect3DStateBlock9 *mMaskedClearSavedState;
// previously set render states
......
......@@ -521,14 +521,14 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
if (readColorBuffer && drawColorBuffer)
{
GLenum readInternalFormat = readColorBuffer->getActualFormat();
GLenum readInternalFormat = readColorBuffer->getInternalFormat();
const InternalFormat &readFormatInfo = GetInternalFormatInfo(readInternalFormat);
for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; i++)
{
if (drawFramebuffer->isEnabledColorAttachment(i))
{
GLenum drawInternalFormat = drawFramebuffer->getColorbuffer(i)->getActualFormat();
GLenum drawInternalFormat = drawFramebuffer->getColorbuffer(i)->getInternalFormat();
const InternalFormat &drawFormatInfo = GetInternalFormatInfo(drawInternalFormat);
// The GL ES 3.0.2 spec (pg 193) states that:
......@@ -628,7 +628,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
if (readBuffer && drawBuffer)
{
if (readBuffer->getActualFormat() != drawBuffer->getActualFormat())
if (readBuffer->getInternalFormat() != drawBuffer->getInternalFormat())
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
......@@ -912,7 +912,7 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize
GLenum currentFormat = framebuffer->getImplementationColorReadFormat();
GLenum currentType = framebuffer->getImplementationColorReadType();
GLenum currentInternalFormat = readBuffer->getActualFormat();
GLenum currentInternalFormat = readBuffer->getInternalFormat();
GLuint clientVersion = context->getClientVersion();
bool validReadFormat = (clientVersion < 3) ? ValidES2ReadFormatType(context, format, type) :
......
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