Implement WebGPU formats on D3D12
BUG=dawn:128 Change-Id: I1a71df25d9b7f003882366f052b83085ac5d1258 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8620 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
3e1bca702c
commit
bb218b8aea
|
@ -97,20 +97,97 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format) {
|
||||
switch (format) {
|
||||
case dawn::TextureFormat::RGBA8Unorm:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
case dawn::TextureFormat::RG8Unorm:
|
||||
return DXGI_FORMAT_R8G8_UNORM;
|
||||
case dawn::TextureFormat::R8Unorm:
|
||||
return DXGI_FORMAT_R8_UNORM;
|
||||
case dawn::TextureFormat::RGBA8Uint:
|
||||
return DXGI_FORMAT_R8G8B8A8_UINT;
|
||||
case dawn::TextureFormat::RG8Uint:
|
||||
return DXGI_FORMAT_R8G8_UINT;
|
||||
case dawn::TextureFormat::R8Snorm:
|
||||
return DXGI_FORMAT_R8_SNORM;
|
||||
case dawn::TextureFormat::R8Uint:
|
||||
return DXGI_FORMAT_R8_UINT;
|
||||
case dawn::TextureFormat::R8Sint:
|
||||
return DXGI_FORMAT_R8_SINT;
|
||||
|
||||
case dawn::TextureFormat::R16Unorm:
|
||||
return DXGI_FORMAT_R16_UNORM;
|
||||
case dawn::TextureFormat::R16Snorm:
|
||||
return DXGI_FORMAT_R16_SNORM;
|
||||
case dawn::TextureFormat::R16Uint:
|
||||
return DXGI_FORMAT_R16_UINT;
|
||||
case dawn::TextureFormat::R16Sint:
|
||||
return DXGI_FORMAT_R16_SINT;
|
||||
case dawn::TextureFormat::R16Float:
|
||||
return DXGI_FORMAT_R16_FLOAT;
|
||||
case dawn::TextureFormat::RG8Unorm:
|
||||
return DXGI_FORMAT_R8G8_UNORM;
|
||||
case dawn::TextureFormat::RG8Snorm:
|
||||
return DXGI_FORMAT_R8G8_SNORM;
|
||||
case dawn::TextureFormat::RG8Uint:
|
||||
return DXGI_FORMAT_R8G8_UINT;
|
||||
case dawn::TextureFormat::RG8Sint:
|
||||
return DXGI_FORMAT_R8G8_SINT;
|
||||
|
||||
case dawn::TextureFormat::R32Uint:
|
||||
return DXGI_FORMAT_R32_UINT;
|
||||
case dawn::TextureFormat::R32Sint:
|
||||
return DXGI_FORMAT_R32_SINT;
|
||||
case dawn::TextureFormat::R32Float:
|
||||
return DXGI_FORMAT_R32_FLOAT;
|
||||
case dawn::TextureFormat::RG16Unorm:
|
||||
return DXGI_FORMAT_R16G16_UNORM;
|
||||
case dawn::TextureFormat::RG16Snorm:
|
||||
return DXGI_FORMAT_R16G16_SNORM;
|
||||
case dawn::TextureFormat::RG16Uint:
|
||||
return DXGI_FORMAT_R16G16_UINT;
|
||||
case dawn::TextureFormat::RG16Sint:
|
||||
return DXGI_FORMAT_R16G16_SINT;
|
||||
case dawn::TextureFormat::RG16Float:
|
||||
return DXGI_FORMAT_R16G16_FLOAT;
|
||||
case dawn::TextureFormat::RGBA8Unorm:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
case dawn::TextureFormat::RGBA8UnormSrgb:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
case dawn::TextureFormat::RGBA8Snorm:
|
||||
return DXGI_FORMAT_R8G8B8A8_SNORM;
|
||||
case dawn::TextureFormat::RGBA8Uint:
|
||||
return DXGI_FORMAT_R8G8B8A8_UINT;
|
||||
case dawn::TextureFormat::RGBA8Sint:
|
||||
return DXGI_FORMAT_R8G8B8A8_SINT;
|
||||
case dawn::TextureFormat::BGRA8Unorm:
|
||||
return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
case dawn::TextureFormat::BGRA8UnormSrgb:
|
||||
return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
||||
case dawn::TextureFormat::RGB10A2Unorm:
|
||||
return DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
case dawn::TextureFormat::RG11B10Float:
|
||||
return DXGI_FORMAT_R11G11B10_FLOAT;
|
||||
|
||||
case dawn::TextureFormat::RG32Uint:
|
||||
return DXGI_FORMAT_R32G32_UINT;
|
||||
case dawn::TextureFormat::RG32Sint:
|
||||
return DXGI_FORMAT_R32G32_SINT;
|
||||
case dawn::TextureFormat::RG32Float:
|
||||
return DXGI_FORMAT_R32G32_FLOAT;
|
||||
case dawn::TextureFormat::RGBA16Unorm:
|
||||
return DXGI_FORMAT_R16G16B16A16_UNORM;
|
||||
case dawn::TextureFormat::RGBA16Snorm:
|
||||
return DXGI_FORMAT_R16G16B16A16_SNORM;
|
||||
case dawn::TextureFormat::RGBA16Uint:
|
||||
return DXGI_FORMAT_R16G16B16A16_UINT;
|
||||
case dawn::TextureFormat::RGBA16Sint:
|
||||
return DXGI_FORMAT_R16G16B16A16_SINT;
|
||||
case dawn::TextureFormat::RGBA16Float:
|
||||
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
|
||||
case dawn::TextureFormat::RGBA32Uint:
|
||||
return DXGI_FORMAT_R32G32B32A32_UINT;
|
||||
case dawn::TextureFormat::RGBA32Sint:
|
||||
return DXGI_FORMAT_R32G32B32A32_SINT;
|
||||
case dawn::TextureFormat::RGBA32Float:
|
||||
return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
|
||||
case dawn::TextureFormat::Depth32Float:
|
||||
return DXGI_FORMAT_D32_FLOAT;
|
||||
case dawn::TextureFormat::Depth24Plus:
|
||||
return DXGI_FORMAT_D32_FLOAT;
|
||||
case dawn::TextureFormat::Depth24PlusStencil8:
|
||||
return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
|
||||
|
||||
|
|
|
@ -141,7 +141,6 @@ class TextureFormatTest : public DawnTest {
|
|||
dawn::ShaderModule vsModule =
|
||||
utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
layout(location=0) out vec2 texCoord;
|
||||
void main() {
|
||||
const vec2 pos[3] = vec2[3](
|
||||
vec2(-3.0f, -1.0f),
|
||||
|
@ -149,7 +148,6 @@ class TextureFormatTest : public DawnTest {
|
|||
vec2( 0.0f, 2.0f)
|
||||
);
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 0.0f, 1.0f);
|
||||
texCoord = gl_Position.xy / 2.0f + vec2(0.5f);
|
||||
})");
|
||||
|
||||
// Compute the prefix needed for GLSL types that handle our texture's data.
|
||||
|
@ -173,13 +171,11 @@ class TextureFormatTest : public DawnTest {
|
|||
fsSource << "#version 450\n";
|
||||
fsSource << "layout(set=0, binding=0) uniform sampler mySampler;\n";
|
||||
fsSource << "layout(set=0, binding=1) uniform " << prefix << "texture2D myTexture;\n";
|
||||
|
||||
fsSource << "layout(location=0) in vec2 texCoord;\n";
|
||||
fsSource << "layout(location=0) out " << prefix << "vec4 fragColor;\n";
|
||||
|
||||
fsSource << "void main() {\n";
|
||||
fsSource << " fragColor = texture(" << prefix
|
||||
<< "sampler2D(myTexture, mySampler), texCoord);\n";
|
||||
fsSource << " fragColor = texelFetch(" << prefix
|
||||
<< "sampler2D(myTexture, mySampler), ivec2(gl_FragCoord), 0);\n";
|
||||
fsSource << "}";
|
||||
|
||||
dawn::ShaderModule fsModule =
|
||||
|
@ -685,4 +681,4 @@ TEST_P(TextureFormatTest, RG11B10Float) {
|
|||
// TODO(cwallez@chromium.org): Add tests for depth-stencil formats when we know if they are copyable
|
||||
// in WebGPU.
|
||||
|
||||
DAWN_INSTANTIATE_TEST(TextureFormatTest, MetalBackend, VulkanBackend);
|
||||
DAWN_INSTANTIATE_TEST(TextureFormatTest, D3D12Backend, MetalBackend, VulkanBackend);
|
||||
|
|
Loading…
Reference in New Issue