diff --git a/src/d3d9/d3d9_format.cpp b/src/d3d9/d3d9_format.cpp index 3f614eeb..438eddea 100644 --- a/src/d3d9/d3d9_format.cpp +++ b/src/d3d9/d3d9_format.cpp @@ -140,7 +140,15 @@ namespace dxvk { // Convert -> float (this is a mixed snorm and unorm type) VK_FORMAT_R16G16B16A16_SFLOAT } }; - case D3D9Format::X8L8V8U8: return {}; // Unsupported + case D3D9Format::X8L8V8U8: return { + VK_FORMAT_B8G8R8A8_UNORM, + VK_FORMAT_UNDEFINED, + VK_IMAGE_ASPECT_COLOR_BIT, + { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, + VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE }, + { D3D9ConversionFormat_X8L8V8U8, { 1u, 1u }, + // Convert -> float (this is a mixed snorm and unorm type) + VK_FORMAT_R16G16B16A16_SFLOAT } }; case D3D9Format::Q8W8V8U8: return { VK_FORMAT_R8G8B8A8_SNORM, diff --git a/src/d3d9/d3d9_format.h b/src/d3d9/d3d9_format.h index 23db27f1..65eed9a6 100644 --- a/src/d3d9/d3d9_format.h +++ b/src/d3d9/d3d9_format.h @@ -132,6 +132,7 @@ namespace dxvk { D3D9ConversionFormat_YUY2 = 1, D3D9ConversionFormat_UYVY, D3D9ConversionFormat_L6V5U5, + D3D9ConversionFormat_X8L8V8U8, D3D9ConversionFormat_Count }; diff --git a/src/d3d9/d3d9_format_helpers.cpp b/src/d3d9/d3d9_format_helpers.cpp index fed01442..0347a5ab 100644 --- a/src/d3d9/d3d9_format_helpers.cpp +++ b/src/d3d9/d3d9_format_helpers.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace dxvk { @@ -32,9 +33,15 @@ namespace dxvk { ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, specConstant); break; } + case D3D9ConversionFormat_L6V5U5: ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R16_UINT, 0); break; + + case D3D9ConversionFormat_X8L8V8U8: + ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, 0); + break; + default: Logger::warn("Unimplemented format conversion"); } @@ -94,6 +101,7 @@ namespace dxvk { m_shaders[D3D9ConversionFormat_YUY2] = InitShader(d3d9_convert_yuy2_uyvy); m_shaders[D3D9ConversionFormat_UYVY] = m_shaders[D3D9ConversionFormat_YUY2]; m_shaders[D3D9ConversionFormat_L6V5U5] = InitShader(d3d9_convert_l6v5u5); + m_shaders[D3D9ConversionFormat_X8L8V8U8] = InitShader(d3d9_convert_x8l8v8u8); } diff --git a/src/d3d9/meson.build b/src/d3d9/meson.build index d122f934..2237594e 100644 --- a/src/d3d9/meson.build +++ b/src/d3d9/meson.build @@ -4,7 +4,8 @@ d3d9_shaders = files([ 'shaders/d3d9_presenter_frag.frag', 'shaders/d3d9_presenter_vert.vert', 'shaders/d3d9_convert_yuy2_uyvy.comp', - 'shaders/d3d9_convert_l6v5u5.comp' + 'shaders/d3d9_convert_l6v5u5.comp', + 'shaders/d3d9_convert_x8l8v8u8.comp' ]) d3d9_src = [ diff --git a/src/d3d9/shaders/d3d9_convert_x8l8v8u8.comp b/src/d3d9/shaders/d3d9_convert_x8l8v8u8.comp new file mode 100644 index 00000000..a9257cb5 --- /dev/null +++ b/src/d3d9/shaders/d3d9_convert_x8l8v8u8.comp @@ -0,0 +1,43 @@ +#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 u8 = bitfieldExtract(int (value), 0, 8); + int v8 = bitfieldExtract(int (value), 8, 8); + uint l8 = bitfieldExtract(uint(value), 16, 8); + + vec4 color = vec4( + snormalize(u8, 8), + snormalize(v8, 8), + unormalize(l8, 8), + 1.0f); + + imageStore(dst, thread_id.xy, color); + } +} \ No newline at end of file