Commit dcd8f13d by Jamie Madill

Revert "Enable TexSubImage workaround on D3D11."

Probably causing WebGL CTS failures: http://build.chromium.org/p/chromium.gpu.fyi/builders/Win8%20Release%20%28NVIDIA%29/builds/6148 This reverts commit 2d337ce0. Change-Id: Ic032640f44adf337c4b3eedd4d7f3551d565a5cb Reviewed-on: https://chromium-review.googlesource.com/221397Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 2d337ce0
...@@ -20,14 +20,12 @@ namespace gl ...@@ -20,14 +20,12 @@ namespace gl
{ {
class Framebuffer; class Framebuffer;
struct Rectangle; struct Rectangle;
struct ImageIndex;
} }
namespace rx namespace rx
{ {
class Renderer; class Renderer;
class RenderTarget; class RenderTarget;
class TextureStorage;
class Image class Image
{ {
...@@ -56,8 +54,6 @@ class Image ...@@ -56,8 +54,6 @@ class Image
void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, gl::Framebuffer *source); void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, gl::Framebuffer *source);
virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source) = 0; virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source) = 0;
virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source) = 0;
protected: protected:
GLsizei mWidth; GLsizei mWidth;
......
...@@ -26,12 +26,10 @@ enum D3DWorkaroundType ...@@ -26,12 +26,10 @@ enum D3DWorkaroundType
struct Workarounds struct Workarounds
{ {
Workarounds() Workarounds()
: mrtPerfWorkaround(false), : mrtPerfWorkaround(false)
setDataFasterThanImageUpload(false)
{} {}
bool mrtPerfWorkaround; bool mrtPerfWorkaround;
bool setDataFasterThanImageUpload;
}; };
} }
......
...@@ -130,7 +130,7 @@ gl::Error TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type, ...@@ -130,7 +130,7 @@ gl::Error TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type,
gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index) GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index)
{ {
const uint8_t *pixelData = static_cast<const uint8_t *>(pixels); const void *pixelData = pixels;
// CPU readback & copy where direct GPU copy is not supported // CPU readback & copy where direct GPU copy is not supported
if (unpack.pixelBuffer.id() != 0) if (unpack.pixelBuffer.id() != 0)
...@@ -140,7 +140,7 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi ...@@ -140,7 +140,7 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi
// TODO: setImage/subImage is the only place outside of renderer that asks for a buffers raw data. // TODO: setImage/subImage is the only place outside of renderer that asks for a buffers raw data.
// This functionality should be moved into renderer and the getData method of BufferImpl removed. // This functionality should be moved into renderer and the getData method of BufferImpl removed.
const void *bufferData = pixelBuffer->getImplementation()->getData(); const void *bufferData = pixelBuffer->getImplementation()->getData();
pixelData = static_cast<const uint8_t *>(bufferData)+offset; pixelData = static_cast<const unsigned char *>(bufferData) + offset;
} }
if (pixelData != NULL) if (pixelData != NULL)
...@@ -148,16 +148,6 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi ...@@ -148,16 +148,6 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi
Image *image = getImage(index); Image *image = getImage(index);
ASSERT(image); ASSERT(image);
gl::InternalFormat internalFormat = gl::GetInternalFormatInfo(image->getInternalFormat());
gl::Box region(xoffset, yoffset, zoffset, width, height, depth);
// TODO(jmadill): Handle compressed internal formats
if (mRenderer->getWorkarounds().setDataFasterThanImageUpload && !internalFormat.compressed)
{
return getNativeTexture()->setData(index, region, image->getInternalFormat(),
type, unpack, pixelData);
}
gl::Error error = image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpack.alignment, gl::Error error = image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpack.alignment,
type, pixelData); type, pixelData);
if (error.isError()) if (error.isError())
...@@ -165,6 +155,7 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi ...@@ -165,6 +155,7 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi
return error; return error;
} }
gl::Box region(xoffset, yoffset, zoffset, width, height, depth);
error = commitRegion(index, region); error = commitRegion(index, region);
if (error.isError()) if (error.isError())
{ {
...@@ -270,37 +261,17 @@ Image *TextureD3D::getBaseLevelImage() const ...@@ -270,37 +261,17 @@ Image *TextureD3D::getBaseLevelImage() const
void TextureD3D::generateMipmaps() void TextureD3D::generateMipmaps()
{ {
// Set up proper mipmap chain in our Image array. // Set up proper image sizes.
initMipmapsImages(); initMipmapsImages();
// We know that all layers have the same dimension, for the texture to be complete // We know that all layers have the same dimension, for the texture to be complete
GLint layerCount = static_cast<GLint>(getLayerCount(0)); GLint layerCount = static_cast<GLint>(getLayerCount(0));
GLint mipCount = mipLevels(); GLint mipCount = mipLevels();
// When making mipmaps with the setData workaround enabled, the texture storage has // The following will create and initialize the storage, or update it if it exists
// the image data already. For non-render-target storage, we have to pull it out into TextureStorage *storage = getNativeTexture();
// an image layer.
if (mRenderer->getWorkarounds().setDataFasterThanImageUpload && mTexStorage)
{
if (!mTexStorage->isRenderTarget())
{
// Copy from the storage mip 0 to Image mip 0
for (GLint layer = 0; layer < layerCount; ++layer)
{
gl::ImageIndex srcIndex = getImageIndex(0, layer);
Image *image = getImage(srcIndex);
gl::Rectangle area(0, 0, image->getWidth(), image->getHeight());
image->copy(0, 0, 0, area, srcIndex, mTexStorage);
}
}
else
{
updateStorage();
}
}
bool renderableStorage = (mTexStorage && mTexStorage->isRenderTarget()); bool renderableStorage = (storage && storage->isRenderTarget());
for (GLint layer = 0; layer < layerCount; ++layer) for (GLint layer = 0; layer < layerCount; ++layer)
{ {
...@@ -314,7 +285,7 @@ void TextureD3D::generateMipmaps() ...@@ -314,7 +285,7 @@ void TextureD3D::generateMipmaps()
if (renderableStorage) if (renderableStorage)
{ {
// GPU-side mipmapping // GPU-side mipmapping
mTexStorage->generateMipmap(sourceIndex, destIndex); storage->generateMipmap(sourceIndex, destIndex);
} }
else else
{ {
......
...@@ -323,54 +323,27 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse ...@@ -323,54 +323,27 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse
void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source) void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source)
{ {
RenderTarget11 *sourceRenderTarget = RenderTarget11::makeRenderTarget11(source); RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(source);
ASSERT(sourceRenderTarget->getTexture()); ASSERT(renderTarget->getTexture());
ID3D11Texture2D *sourceTexture2D = d3d11::DynamicCastComObject<ID3D11Texture2D>(sourceRenderTarget->getTexture()); ID3D11Texture2D *colorBufferTexture = d3d11::DynamicCastComObject<ID3D11Texture2D>(renderTarget->getTexture());
unsigned int subresourceIndex = sourceRenderTarget->getSubresourceIndex(); unsigned int subresourceIndex = renderTarget->getSubresourceIndex();
if (!sourceTexture2D) if (!colorBufferTexture)
{ {
// Error already generated // Error already generated
return; return;
} }
copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex); if (source->getActualFormat() == mActualFormat)
}
void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, const gl::ImageIndex &sourceIndex, TextureStorage *source)
{
TextureStorage11 *sourceStorage11 = TextureStorage11::makeTextureStorage11(source);
UINT subresourceIndex = sourceStorage11->getSubresourceIndex(sourceIndex.mipIndex, sourceIndex.layerIndex);
ID3D11Texture2D *sourceTexture2D = d3d11::DynamicCastComObject<ID3D11Texture2D>(sourceStorage11->getResource());
if (!sourceTexture2D)
{
// Error already generated
return;
}
copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex);
}
void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, ID3D11Texture2D *source, UINT sourceSubResource)
{
// TODO(jmadill): get the actual/native/dxgi format without a GetDesc query
D3D11_TEXTURE2D_DESC sourceDesc;
source->GetDesc(&sourceDesc);
if (sourceDesc.Format == mDXGIFormat)
{ {
// No conversion needed-- use copyback fastpath // No conversion needed-- use copyback fastpath
D3D11_TEXTURE2D_DESC textureDesc; D3D11_TEXTURE2D_DESC textureDesc;
source->GetDesc(&textureDesc); colorBufferTexture->GetDesc(&textureDesc);
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
UINT subresourceAfterResolve = sourceSubResource;
ID3D11Texture2D* srcTex = NULL; ID3D11Texture2D* srcTex = NULL;
if (textureDesc.SampleDesc.Count > 1) if (textureDesc.SampleDesc.Count > 1)
{ {
...@@ -394,12 +367,12 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan ...@@ -394,12 +367,12 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan
return; return;
} }
deviceContext->ResolveSubresource(srcTex, 0, source, sourceSubResource, textureDesc.Format); deviceContext->ResolveSubresource(srcTex, 0, colorBufferTexture, subresourceIndex, textureDesc.Format);
subresourceAfterResolve = 0; subresourceIndex = 0;
} }
else else
{ {
srcTex = source; srcTex = colorBufferTexture;
srcTex->AddRef(); srcTex->AddRef();
} }
...@@ -411,10 +384,10 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan ...@@ -411,10 +384,10 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan
srcBox.front = 0; srcBox.front = 0;
srcBox.back = 1; srcBox.back = 1;
deviceContext->CopySubresourceRegion(mStagingTexture, 0, xoffset, yoffset, zoffset, srcTex, subresourceAfterResolve, &srcBox); deviceContext->CopySubresourceRegion(mStagingTexture, 0, xoffset, yoffset, zoffset, srcTex, subresourceIndex, &srcBox);
SafeRelease(srcTex); SafeRelease(srcTex);
SafeRelease(source); SafeRelease(colorBufferTexture);
} }
else else
{ {
...@@ -433,7 +406,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan ...@@ -433,7 +406,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
mRenderer->readTextureData(source, sourceSubResource, sourceArea, formatInfo.format, formatInfo.type, mappedImage.RowPitch, gl::PixelPackState(), dataOffset); mRenderer->readTextureData(colorBufferTexture, subresourceIndex, sourceArea, formatInfo.format, formatInfo.type, mappedImage.RowPitch, gl::PixelPackState(), dataOffset);
unmap(); unmap();
} }
......
...@@ -52,8 +52,6 @@ class Image11 : public ImageD3D ...@@ -52,8 +52,6 @@ class Image11 : public ImageD3D
const void *input); const void *input);
virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source); virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source);
virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source);
bool recoverFromAssociatedStorage(); bool recoverFromAssociatedStorage();
bool isAssociatedStorageValid(TextureStorage11* textureStorage) const; bool isAssociatedStorageValid(TextureStorage11* textureStorage) const;
...@@ -67,7 +65,6 @@ class Image11 : public ImageD3D ...@@ -67,7 +65,6 @@ class Image11 : public ImageD3D
DISALLOW_COPY_AND_ASSIGN(Image11); DISALLOW_COPY_AND_ASSIGN(Image11);
gl::Error copyToStorageImpl(TextureStorage11 *storage11, int level, int layerTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); gl::Error copyToStorageImpl(TextureStorage11 *storage11, int level, int layerTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, ID3D11Texture2D *source, UINT sourceSubResource);
ID3D11Resource *getStagingTexture(); ID3D11Resource *getStagingTexture();
unsigned int getStagingSubresource(); unsigned int getStagingSubresource();
......
...@@ -1076,7 +1076,6 @@ Workarounds GenerateWorkarounds() ...@@ -1076,7 +1076,6 @@ Workarounds GenerateWorkarounds()
{ {
Workarounds workarounds; Workarounds workarounds;
workarounds.mrtPerfWorkaround = true; workarounds.mrtPerfWorkaround = true;
workarounds.setDataFasterThanImageUpload = true;
return workarounds; return workarounds;
} }
......
...@@ -717,10 +717,4 @@ void Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectang ...@@ -717,10 +717,4 @@ void Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectang
mDirty = true; mDirty = true;
} }
void Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &area, const gl::ImageIndex &srcIndex, TextureStorage *srcStorage)
{
// Currently unreachable, due to only being used in a D3D11-only workaround
UNIMPLEMENTED();
}
} }
...@@ -55,8 +55,6 @@ class Image9 : public ImageD3D ...@@ -55,8 +55,6 @@ class Image9 : public ImageD3D
const void *input); const void *input);
virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source); virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source);
virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source);
private: private:
DISALLOW_COPY_AND_ASSIGN(Image9); DISALLOW_COPY_AND_ASSIGN(Image9);
......
...@@ -543,7 +543,6 @@ Workarounds GenerateWorkarounds() ...@@ -543,7 +543,6 @@ Workarounds GenerateWorkarounds()
{ {
Workarounds workarounds; Workarounds workarounds;
workarounds.mrtPerfWorkaround = true; workarounds.mrtPerfWorkaround = true;
workarounds.setDataFasterThanImageUpload = false;
return workarounds; return workarounds;
} }
......
...@@ -40,11 +40,9 @@ protected: ...@@ -40,11 +40,9 @@ protected:
attribute vec4 position; attribute vec4 position;
varying vec2 texcoord; varying vec2 texcoord;
uniform vec2 textureScale;
void main() void main()
{ {
gl_Position = vec4(position.xy * textureScale, 0.0, 1.0); gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5; texcoord = (position.xy * 0.5) + 0.5;
} }
); );
...@@ -83,15 +81,6 @@ protected: ...@@ -83,15 +81,6 @@ protected:
} }
mTexture2DUniformLocation = glGetUniformLocation(m2DProgram, "tex"); mTexture2DUniformLocation = glGetUniformLocation(m2DProgram, "tex");
ASSERT_NE(-1, mTexture2DUniformLocation);
mTextureScaleUniformLocation = glGetUniformLocation(m2DProgram, "textureScale");
ASSERT_NE(-1, mTextureScaleUniformLocation);
glUseProgram(m2DProgram);
glUniform2f(mTextureScaleUniformLocation, 1.0f, 1.0f);
glUseProgram(0);
ASSERT_GL_NO_ERROR();
} }
virtual void TearDown() virtual void TearDown()
...@@ -110,7 +99,6 @@ protected: ...@@ -110,7 +99,6 @@ protected:
GLuint m2DProgram; GLuint m2DProgram;
GLuint mCubeProgram; GLuint mCubeProgram;
GLint mTexture2DUniformLocation; GLint mTexture2DUniformLocation;
GLint mTextureScaleUniformLocation;
}; };
TYPED_TEST(TextureTest, NegativeAPISubImage) TYPED_TEST(TextureTest, NegativeAPISubImage)
...@@ -164,63 +152,3 @@ TYPED_TEST(TextureTest, CubeMapBug) ...@@ -164,63 +152,3 @@ TYPED_TEST(TextureTest, CubeMapBug)
drawQuad(mCubeProgram, "position", 0.5f); drawQuad(mCubeProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
// Copy of a test in conformance/textures/texture-mips, to test generate mipmaps
TYPED_TEST(TextureTest, MipmapsTwice)
{
int px = getWindowWidth() / 2;
int py = getWindowHeight() / 2;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mTexture2D);
// Fill with red
std::vector<GLubyte> pixels(4 * 16 * 16);
for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId)
{
pixels[pixelId * 4 + 0] = 255;
pixels[pixelId * 4 + 1] = 0;
pixels[pixelId * 4 + 2] = 0;
pixels[pixelId * 4 + 3] = 255;
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glGenerateMipmap(GL_TEXTURE_2D);
glUseProgram(m2DProgram);
glUniform1i(mTexture2DUniformLocation, 0);
glUniform2f(mTextureScaleUniformLocation, 0.0625f, 0.0625f);
drawQuad(m2DProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR();
EXPECT_PIXEL_EQ(px, py, 255, 0, 0, 255);
// Fill with blue
for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId)
{
pixels[pixelId * 4 + 0] = 0;
pixels[pixelId * 4 + 1] = 0;
pixels[pixelId * 4 + 2] = 255;
pixels[pixelId * 4 + 3] = 255;
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
glGenerateMipmap(GL_TEXTURE_2D);
// Fill with green
for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId)
{
pixels[pixelId * 4 + 0] = 0;
pixels[pixelId * 4 + 1] = 255;
pixels[pixelId * 4 + 2] = 0;
pixels[pixelId * 4 + 3] = 255;
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
glGenerateMipmap(GL_TEXTURE_2D);
drawQuad(m2DProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR();
EXPECT_PIXEL_EQ(px, py, 0, 255, 0, 255);
}
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