Commit 46258e1f by Geoff Lang Committed by Commit Bot

Blit9: Pass the dest rect to setViewportAndShaderConstants.

Using the sourceRect for calculating the viewport and texture coordinates was not enough when the source and destination rectangles were different sizes (generating mipmaps). BUG=709232 Change-Id: I2704ddf6e3da0939ad77d278ab495e53a2d9bc7d Reviewed-on: https://chromium-review.googlesource.com/473266 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent eb8abb0a
...@@ -220,8 +220,8 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest) ...@@ -220,8 +220,8 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
setViewportAndShaderConstants(getSurfaceRect(dest), getSurfaceSize(source), gl::Offset(0, 0, 0), setViewportAndShaderConstants(getSurfaceRect(source), getSurfaceSize(source),
false); getSurfaceRect(dest), false);
render(); render();
...@@ -442,7 +442,13 @@ gl::Error Blit9::formatConvert(IDirect3DBaseTexture9 *source, ...@@ -442,7 +442,13 @@ gl::Error Blit9::formatConvert(IDirect3DBaseTexture9 *source,
device->SetTexture(0, source); device->SetTexture(0, source);
device->SetRenderTarget(0, dest); device->SetRenderTarget(0, dest);
setViewportAndShaderConstants(sourceRect, sourceSize, destOffset, flipY); RECT destRect;
destRect.left = destOffset.x;
destRect.right = destOffset.x + (sourceRect.right - sourceRect.left);
destRect.top = destOffset.y;
destRect.bottom = destOffset.y + (sourceRect.bottom - sourceRect.top);
setViewportAndShaderConstants(sourceRect, sourceSize, destRect, flipY);
setCommonBlitState(); setCommonBlitState();
...@@ -653,16 +659,16 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, ...@@ -653,16 +659,16 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface,
void Blit9::setViewportAndShaderConstants(const RECT &sourceRect, void Blit9::setViewportAndShaderConstants(const RECT &sourceRect,
const gl::Extents &sourceSize, const gl::Extents &sourceSize,
const gl::Offset &offset, const RECT &destRect,
bool flipY) bool flipY)
{ {
IDirect3DDevice9 *device = mRenderer->getDevice(); IDirect3DDevice9 *device = mRenderer->getDevice();
D3DVIEWPORT9 vp; D3DVIEWPORT9 vp;
vp.X = offset.x; vp.X = destRect.left;
vp.Y = offset.y; vp.Y = destRect.top;
vp.Width = sourceRect.right - sourceRect.left; vp.Width = destRect.right - destRect.left;
vp.Height = sourceRect.bottom - sourceRect.top; vp.Height = destRect.bottom - destRect.top;
vp.MinZ = 0.0f; vp.MinZ = 0.0f;
vp.MaxZ = 1.0f; vp.MaxZ = 1.0f;
device->SetViewport(&vp); device->SetViewport(&vp);
......
...@@ -99,7 +99,7 @@ class Blit9 : angle::NonCopyable ...@@ -99,7 +99,7 @@ class Blit9 : angle::NonCopyable
IDirect3DBaseTexture9 **outTexture); IDirect3DBaseTexture9 **outTexture);
void setViewportAndShaderConstants(const RECT &sourceRect, void setViewportAndShaderConstants(const RECT &sourceRect,
const gl::Extents &sourceSize, const gl::Extents &sourceSize,
const gl::Offset &offset, const RECT &destRect,
bool flipY); bool flipY);
void setCommonBlitState(); void setCommonBlitState();
RECT getSurfaceRect(IDirect3DSurface9 *surface) const; RECT getSurfaceRect(IDirect3DSurface9 *surface) const;
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "test_utils/ANGLETest.h" #include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
using namespace angle; using namespace angle;
namespace namespace
...@@ -683,6 +685,34 @@ TEST_P(MipmapTest, RenderOntoLevelZeroAfterGenerateMipmap) ...@@ -683,6 +685,34 @@ TEST_P(MipmapTest, RenderOntoLevelZeroAfterGenerateMipmap)
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 8, getWindowHeight() / 8, GLColor::green); EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 8, getWindowHeight() / 8, GLColor::green);
} }
// Regression test for a bug that cause mipmaps to only generate using the top left corner as input.
TEST_P(MipmapTest, MipMapGenerationD3D9Bug)
{
if (!extensionEnabled("GL_EXT_texture_storage") || !extensionEnabled("GL_OES_rgb8_rgba8") ||
!extensionEnabled("GL_ANGLE_texture_usage"))
{
std::cout << "Test skipped due to missing extensions." << std::endl;
return;
}
const GLColor mip0Color[4] = {
GLColor::red, GLColor::green, GLColor::red, GLColor::green,
};
const GLColor mip1Color = GLColor(127, 127, 0, 255);
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture.get());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGBA8_OES, 2, 2);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, mip0Color);
glGenerateMipmap(GL_TEXTURE_2D);
// Only draw to a 1 pixel viewport so the lower mip is used
clearAndDrawQuad(m2DProgram, 1, 1);
EXPECT_PIXEL_COLOR_NEAR(0, 0, mip1Color, 1.0);
}
// This test ensures that the level-zero workaround for TextureCubes (on D3D11 Feature Level 9_3) // This test ensures that the level-zero workaround for TextureCubes (on D3D11 Feature Level 9_3)
// works as expected. It tests enabling/disabling mipmaps, generating mipmaps, and rendering to level zero. // works as expected. It tests enabling/disabling mipmaps, generating mipmaps, and rendering to level zero.
TEST_P(MipmapTest, TextureCubeGeneralLevelZero) TEST_P(MipmapTest, TextureCubeGeneralLevelZero)
......
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