1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 10:24:10 +01:00

[d3d9] Implement X8L8V8U8 format via conversion

This commit is contained in:
Joshua Ashton 2020-03-08 23:22:52 +00:00
parent afd4e6e457
commit 60ec7e8208
5 changed files with 63 additions and 2 deletions

View File

@ -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,

View File

@ -132,6 +132,7 @@ namespace dxvk {
D3D9ConversionFormat_YUY2 = 1,
D3D9ConversionFormat_UYVY,
D3D9ConversionFormat_L6V5U5,
D3D9ConversionFormat_X8L8V8U8,
D3D9ConversionFormat_Count
};

View File

@ -2,6 +2,7 @@
#include <d3d9_convert_yuy2_uyvy.h>
#include <d3d9_convert_l6v5u5.h>
#include <d3d9_convert_x8l8v8u8.h>
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);
}

View File

@ -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 = [

View File

@ -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);
}
}