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
{
class Framebuffer;
struct Rectangle;
struct ImageIndex;
}
namespace rx
{
class Renderer;
class RenderTarget;
class TextureStorage;
class Image
{
......@@ -56,8 +54,6 @@ class Image
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,
const gl::ImageIndex &sourceIndex, TextureStorage *source) = 0;
protected:
GLsizei mWidth;
......
......@@ -26,12 +26,10 @@ enum D3DWorkaroundType
struct Workarounds
{
Workarounds()
: mrtPerfWorkaround(false),
setDataFasterThanImageUpload(false)
: mrtPerfWorkaround(false)
{}
bool mrtPerfWorkaround;
bool setDataFasterThanImageUpload;
};
}
......
......@@ -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,
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
if (unpack.pixelBuffer.id() != 0)
......@@ -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.
// This functionality should be moved into renderer and the getData method of BufferImpl removed.
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)
......@@ -148,16 +148,6 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi
Image *image = getImage(index);
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,
type, pixelData);
if (error.isError())
......@@ -165,6 +155,7 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi
return error;
}
gl::Box region(xoffset, yoffset, zoffset, width, height, depth);
error = commitRegion(index, region);
if (error.isError())
{
......@@ -270,37 +261,17 @@ Image *TextureD3D::getBaseLevelImage() const
void TextureD3D::generateMipmaps()
{
// Set up proper mipmap chain in our Image array.
// Set up proper image sizes.
initMipmapsImages();
// We know that all layers have the same dimension, for the texture to be complete
GLint layerCount = static_cast<GLint>(getLayerCount(0));
GLint mipCount = mipLevels();
// When making mipmaps with the setData workaround enabled, the texture storage has
// the image data already. For non-render-target storage, we have to pull it out into
// 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();
}
}
// The following will create and initialize the storage, or update it if it exists
TextureStorage *storage = getNativeTexture();
bool renderableStorage = (mTexStorage && mTexStorage->isRenderTarget());
bool renderableStorage = (storage && storage->isRenderTarget());
for (GLint layer = 0; layer < layerCount; ++layer)
{
......@@ -314,7 +285,7 @@ void TextureD3D::generateMipmaps()
if (renderableStorage)
{
// GPU-side mipmapping
mTexStorage->generateMipmap(sourceIndex, destIndex);
storage->generateMipmap(sourceIndex, destIndex);
}
else
{
......
......@@ -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)
{
RenderTarget11 *sourceRenderTarget = RenderTarget11::makeRenderTarget11(source);
ASSERT(sourceRenderTarget->getTexture());
RenderTarget11 *renderTarget = RenderTarget11::makeRenderTarget11(source);
ASSERT(renderTarget->getTexture());
ID3D11Texture2D *sourceTexture2D = d3d11::DynamicCastComObject<ID3D11Texture2D>(sourceRenderTarget->getTexture());
unsigned int subresourceIndex = sourceRenderTarget->getSubresourceIndex();
ID3D11Texture2D *colorBufferTexture = d3d11::DynamicCastComObject<ID3D11Texture2D>(renderTarget->getTexture());
unsigned int subresourceIndex = renderTarget->getSubresourceIndex();
if (!sourceTexture2D)
if (!colorBufferTexture)
{
// Error already generated
return;
}
copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex);
}
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)
if (source->getActualFormat() == mActualFormat)
{
// No conversion needed-- use copyback fastpath
D3D11_TEXTURE2D_DESC textureDesc;
source->GetDesc(&textureDesc);
colorBufferTexture->GetDesc(&textureDesc);
ID3D11Device *device = mRenderer->getDevice();
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
UINT subresourceAfterResolve = sourceSubResource;
ID3D11Texture2D* srcTex = NULL;
if (textureDesc.SampleDesc.Count > 1)
{
......@@ -394,12 +367,12 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan
return;
}
deviceContext->ResolveSubresource(srcTex, 0, source, sourceSubResource, textureDesc.Format);
subresourceAfterResolve = 0;
deviceContext->ResolveSubresource(srcTex, 0, colorBufferTexture, subresourceIndex, textureDesc.Format);
subresourceIndex = 0;
}
else
{
srcTex = source;
srcTex = colorBufferTexture;
srcTex->AddRef();
}
......@@ -411,10 +384,10 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan
srcBox.front = 0;
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(source);
SafeRelease(colorBufferTexture);
}
else
{
......@@ -433,7 +406,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectan
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();
}
......
......@@ -52,8 +52,6 @@ class Image11 : public ImageD3D
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,
const gl::ImageIndex &sourceIndex, TextureStorage *source);
bool recoverFromAssociatedStorage();
bool isAssociatedStorageValid(TextureStorage11* textureStorage) const;
......@@ -67,7 +65,6 @@ class Image11 : public ImageD3D
DISALLOW_COPY_AND_ASSIGN(Image11);
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();
unsigned int getStagingSubresource();
......
......@@ -1076,7 +1076,6 @@ Workarounds GenerateWorkarounds()
{
Workarounds workarounds;
workarounds.mrtPerfWorkaround = true;
workarounds.setDataFasterThanImageUpload = true;
return workarounds;
}
......
......@@ -717,10 +717,4 @@ void Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectang
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
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,
const gl::ImageIndex &sourceIndex, TextureStorage *source);
private:
DISALLOW_COPY_AND_ASSIGN(Image9);
......
......@@ -543,7 +543,6 @@ Workarounds GenerateWorkarounds()
{
Workarounds workarounds;
workarounds.mrtPerfWorkaround = true;
workarounds.setDataFasterThanImageUpload = false;
return workarounds;
}
......
......@@ -40,11 +40,9 @@ protected:
attribute vec4 position;
varying vec2 texcoord;
uniform vec2 textureScale;
void main()
{
gl_Position = vec4(position.xy * textureScale, 0.0, 1.0);
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
}
);
......@@ -83,15 +81,6 @@ protected:
}
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()
......@@ -110,7 +99,6 @@ protected:
GLuint m2DProgram;
GLuint mCubeProgram;
GLint mTexture2DUniformLocation;
GLint mTextureScaleUniformLocation;
};
TYPED_TEST(TextureTest, NegativeAPISubImage)
......@@ -164,63 +152,3 @@ TYPED_TEST(TextureTest, CubeMapBug)
drawQuad(mCubeProgram, "position", 0.5f);
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