Commit b1853096 by Olli Etuaho

D3D11: Don't use DXGI to GL format map in copy functions

The swizzle or copy shader needs to be chosen according to the component type of the source SRV. Before this patch, the component type was obtained by going through the mapping from the SRV DXGI formats to GL formats. This mapping is problematic, because it has entries that don't really make sense, like R16_UNORM and R16_TYPELESS formats being mapped to GL_DEPTH_COMPONENT16. This is an issue particularly because these formats will be used for integer RED textures in the future. For this reason the mapping should be removed. In the case addressed by this specific commit, rather than look up the component type of the SRV indirectly through the GL format table using the GL internal format that corresponds to the DXGI format, just use the component type of the DXGI format. The depth+stencil swizzle cases where the component type is not well defined are handled as a special case. BUG=angleproject:1244 TEST=angle_end2end_tests, dEQP-GLES3.functional.texture.swizzle.* (all pass), dEQP-GLES3.functional.fbo.blit.* (no regressions) Change-Id: I39fb8a14921b89d299e0077b3bea8b4e66ef218d Reviewed-on: https://chromium-review.googlesource.com/329103 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 713e4db7
...@@ -626,10 +626,26 @@ gl::Error Blit11::swizzleTexture(ID3D11ShaderResourceView *source, ...@@ -626,10 +626,26 @@ gl::Error Blit11::swizzleTexture(ID3D11ShaderResourceView *source,
source->GetDesc(&sourceSRVDesc); source->GetDesc(&sourceSRVDesc);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(sourceSRVDesc.Format); const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(sourceSRVDesc.Format);
const gl::InternalFormat &sourceFormatInfo = gl::GetInternalFormatInfo(dxgiFormatInfo.internalFormat); GLenum componentType = dxgiFormatInfo.componentType;
if (componentType == GL_NONE)
{
// We're swizzling the depth component of a depth-stencil texture.
switch (sourceSRVDesc.Format)
{
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
componentType = GL_UNSIGNED_NORMALIZED;
break;
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
componentType = GL_FLOAT;
break;
default:
UNREACHABLE();
break;
}
}
GLenum shaderType = GL_NONE; GLenum shaderType = GL_NONE;
switch (sourceFormatInfo.componentType) switch (componentType)
{ {
case GL_UNSIGNED_NORMALIZED: case GL_UNSIGNED_NORMALIZED:
case GL_SIGNED_NORMALIZED: case GL_SIGNED_NORMALIZED:
...@@ -774,9 +790,12 @@ gl::Error Blit11::copyTexture(ID3D11ShaderResourceView *source, ...@@ -774,9 +790,12 @@ gl::Error Blit11::copyTexture(ID3D11ShaderResourceView *source,
source->GetDesc(&sourceSRVDesc); source->GetDesc(&sourceSRVDesc);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(sourceSRVDesc.Format); const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(sourceSRVDesc.Format);
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(dxgiFormatInfo.internalFormat); GLenum componentType = dxgiFormatInfo.componentType;
ASSERT(componentType != GL_NONE);
ASSERT(componentType != GL_SIGNED_NORMALIZED);
bool isSigned = (componentType == GL_INT);
bool isSigned = (internalFormatInfo.componentType == GL_INT);
ShaderDimension dimension = (sourceSRVDesc.ViewDimension == D3D11_SRV_DIMENSION_TEXTURE3D) ? SHADER_3D : SHADER_2D; ShaderDimension dimension = (sourceSRVDesc.ViewDimension == D3D11_SRV_DIMENSION_TEXTURE3D) ? SHADER_3D : SHADER_2D;
const Shader *shader = nullptr; const Shader *shader = nullptr;
......
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