diff --git a/src/d3d9/d3d9_format.cpp b/src/d3d9/d3d9_format.cpp index 438eddea2..7e34badb3 100644 --- a/src/d3d9/d3d9_format.cpp +++ b/src/d3d9/d3d9_format.cpp @@ -162,7 +162,15 @@ namespace dxvk { { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_ONE, VK_COMPONENT_SWIZZLE_ONE }}; - case D3D9Format::A2W10V10U10: return {}; // Unsupported + case D3D9Format::A2W10V10U10: return { + VK_FORMAT_A2B10G10R10_UNORM_PACK32, + VK_FORMAT_UNDEFINED, + VK_IMAGE_ASPECT_COLOR_BIT, + { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, + VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }, + { D3D9ConversionFormat_A2W10V10U10, { 1u, 1u }, + // Convert -> float (this is a mixed snorm and unorm type) + VK_FORMAT_R16G16B16A16_SFLOAT } }; case D3D9Format::UYVY: return { VK_FORMAT_B8G8R8A8_UNORM, diff --git a/src/d3d9/d3d9_format.h b/src/d3d9/d3d9_format.h index 65eed9a68..4aa87f584 100644 --- a/src/d3d9/d3d9_format.h +++ b/src/d3d9/d3d9_format.h @@ -133,6 +133,7 @@ namespace dxvk { D3D9ConversionFormat_UYVY, D3D9ConversionFormat_L6V5U5, D3D9ConversionFormat_X8L8V8U8, + D3D9ConversionFormat_A2W10V10U10, D3D9ConversionFormat_Count }; diff --git a/src/d3d9/d3d9_format_helpers.cpp b/src/d3d9/d3d9_format_helpers.cpp index 0347a5ab0..7bd3b2dd5 100644 --- a/src/d3d9/d3d9_format_helpers.cpp +++ b/src/d3d9/d3d9_format_helpers.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace dxvk { @@ -42,6 +43,10 @@ namespace dxvk { ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, 0); break; + case D3D9ConversionFormat_A2W10V10U10: + ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, 0); + break; + default: Logger::warn("Unimplemented format conversion"); } @@ -102,6 +107,7 @@ namespace dxvk { m_shaders[D3D9ConversionFormat_UYVY] = m_shaders[D3D9ConversionFormat_YUY2]; m_shaders[D3D9ConversionFormat_L6V5U5] = InitShader(d3d9_convert_l6v5u5); m_shaders[D3D9ConversionFormat_X8L8V8U8] = InitShader(d3d9_convert_x8l8v8u8); + m_shaders[D3D9ConversionFormat_A2W10V10U10] = InitShader(d3d9_convert_a2w10v10u10); } diff --git a/src/d3d9/meson.build b/src/d3d9/meson.build index 2237594e9..2c28d03af 100644 --- a/src/d3d9/meson.build +++ b/src/d3d9/meson.build @@ -5,7 +5,8 @@ d3d9_shaders = files([ 'shaders/d3d9_presenter_vert.vert', 'shaders/d3d9_convert_yuy2_uyvy.comp', 'shaders/d3d9_convert_l6v5u5.comp', - 'shaders/d3d9_convert_x8l8v8u8.comp' + 'shaders/d3d9_convert_x8l8v8u8.comp', + 'shaders/d3d9_convert_a2w10v10u10.comp' ]) d3d9_src = [ diff --git a/src/d3d9/shaders/d3d9_convert_a2w10v10u10.comp b/src/d3d9/shaders/d3d9_convert_a2w10v10u10.comp new file mode 100644 index 000000000..2d489e3d3 --- /dev/null +++ b/src/d3d9/shaders/d3d9_convert_a2w10v10u10.comp @@ -0,0 +1,44 @@ +#version 450 +#extension GL_GOOGLE_include_directive : enable + +#include "d3d9_convert_common.h" + +layout( + local_size_x = 8, + local_size_y = 8, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform image2D dst; + +layout(binding = 1) uniform usamplerBuffer src; + +layout(push_constant) +uniform u_info_t { + uvec2 extent; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID); + + if (all(lessThan(thread_id.xy, u_info.extent))) { + uint offset = thread_id.x + + thread_id.y * u_info.extent.x; + + uint value = texelFetch(src, int(offset)).r; + + // Sign-extend magic! + int u10 = bitfieldExtract(int (value), 0, 10); + int v10 = bitfieldExtract(int (value), 10, 10); + int w10 = bitfieldExtract(int (value), 20, 10); + uint a2 = bitfieldExtract(uint(value), 30, 2); + + vec4 color = vec4( + snormalize(u10, 10), + snormalize(v10, 10), + snormalize(w10, 10), + unormalize(a2, 2)); + + imageStore(dst, thread_id.xy, color); + } +} \ No newline at end of file