Skip to content

Commit

Permalink
[d3d9] Use uniform texel buffers for conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Ashton committed Mar 2, 2020
1 parent 71dd47c commit 8fdb788
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/d3d9/d3d9_common_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace dxvk {
| VK_ACCESS_TRANSFER_WRITE_BIT;

if (m_mapping.ConversionFormatInfo.FormatType != D3D9ConversionFormat_None) {
info.usage |= VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
info.usage |= VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
info.stages |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
}

Expand Down
4 changes: 2 additions & 2 deletions src/d3d9/d3d9_format_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ namespace dxvk {

Rc<DxvkShader> D3D9FormatHelper::InitShader(SpirvCodeBuffer code) {
const std::array<DxvkResourceSlot, 2> resourceSlots = { {
{ BindingIds::Image, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_IMAGE_VIEW_TYPE_2D },
{ BindingIds::Buffer, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_IMAGE_VIEW_TYPE_1D },
{ BindingIds::Image, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_IMAGE_VIEW_TYPE_2D },
{ BindingIds::Buffer, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, VK_IMAGE_VIEW_TYPE_1D },
} };

return m_device->createShader(
Expand Down
8 changes: 2 additions & 6 deletions src/d3d9/shaders/d3d9_convert_l6v5u5.comp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#version 450
#extension GL_EXT_shader_16bit_storage : enable

layout(
local_size_x = 8,
Expand All @@ -9,10 +8,7 @@ layout(
layout(binding = 0)
writeonly uniform image2D dst;

layout(binding = 1)
readonly buffer _buffer_t {
uint16_t data[];
} src;
layout(binding = 1) uniform usamplerBuffer src;

layout(push_constant)
uniform u_info_t {
Expand Down Expand Up @@ -40,7 +36,7 @@ void main() {
uint offset = thread_id.x
+ thread_id.y * u_info.extent.x;

uint value = uint(src.data[offset]);
uint value = texelFetch(src, int(offset)).r;

// Sign-extend magic!
int u5 = bitfieldExtract(int (value), 0, 5);
Expand Down
9 changes: 4 additions & 5 deletions src/d3d9/shaders/d3d9_convert_yuy2_uyvy.comp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ layout(
layout(binding = 0)
writeonly uniform image2D dst;

layout(binding = 1)
readonly buffer yuy2_buffer_t {
uint data[];
} src;
layout(binding = 1) uniform usamplerBuffer src;

layout(push_constant)
uniform u_info_t {
Expand All @@ -39,7 +36,9 @@ void main() {
uint offset = thread_id.x
+ thread_id.y * u_info.extent.x;

vec4 data = unpackUnorm4x8(src.data[offset]);
uint value = texelFetch(src, int(offset)).r;

vec4 data = unpackUnorm4x8(value);

// Flip around stuff for UYVY
if (s_is_uyvy)
Expand Down

0 comments on commit 8fdb788

Please sign in to comment.