From 6a0ab1904963239c09245a5644071262f74af717 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 11 Apr 2018 13:07:04 +0200 Subject: [PATCH] [dxvk] Added meta shaders for image/buffer clear operations The D3D11 ClearUnorderedAccessView* and ClearView functions will have to be emulated using compute shaders rather than clear operations, since Vulkan clear operations do not take image views and their format into account. --- src/dxvk/shaders/dxvk_clear_buffer_f.comp | 23 ++++++++++++++++++++++ src/dxvk/shaders/dxvk_clear_buffer_u.comp | 23 ++++++++++++++++++++++ src/dxvk/shaders/dxvk_clear_image1d_f.comp | 23 ++++++++++++++++++++++ src/dxvk/shaders/dxvk_clear_image1d_u.comp | 23 ++++++++++++++++++++++ src/dxvk/shaders/dxvk_clear_image2d_f.comp | 23 ++++++++++++++++++++++ src/dxvk/shaders/dxvk_clear_image2d_u.comp | 23 ++++++++++++++++++++++ src/dxvk/shaders/dxvk_clear_image3d_f.comp | 23 ++++++++++++++++++++++ src/dxvk/shaders/dxvk_clear_image3d_u.comp | 23 ++++++++++++++++++++++ 8 files changed, 184 insertions(+) create mode 100644 src/dxvk/shaders/dxvk_clear_buffer_f.comp create mode 100644 src/dxvk/shaders/dxvk_clear_buffer_u.comp create mode 100644 src/dxvk/shaders/dxvk_clear_image1d_f.comp create mode 100644 src/dxvk/shaders/dxvk_clear_image1d_u.comp create mode 100644 src/dxvk/shaders/dxvk_clear_image2d_f.comp create mode 100644 src/dxvk/shaders/dxvk_clear_image2d_u.comp create mode 100644 src/dxvk/shaders/dxvk_clear_image3d_f.comp create mode 100644 src/dxvk/shaders/dxvk_clear_image3d_u.comp diff --git a/src/dxvk/shaders/dxvk_clear_buffer_f.comp b/src/dxvk/shaders/dxvk_clear_buffer_f.comp new file mode 100644 index 00000000..1b0af94a --- /dev/null +++ b/src/dxvk/shaders/dxvk_clear_buffer_f.comp @@ -0,0 +1,23 @@ +#version 450 + +layout( + local_size_x = 64, + local_size_y = 1, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform imageBuffer dst; + +layout(push_constant) +uniform u_info_t { + vec4 clear_value; + ivec4 dst_offset; + ivec4 dst_size; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID.x); + + if (thread_id.x < u_info.dst_size.x) + imageStore(dst, thread_id.x + u_info.dst_offset.x, u_info.clear_value); +} \ No newline at end of file diff --git a/src/dxvk/shaders/dxvk_clear_buffer_u.comp b/src/dxvk/shaders/dxvk_clear_buffer_u.comp new file mode 100644 index 00000000..40371354 --- /dev/null +++ b/src/dxvk/shaders/dxvk_clear_buffer_u.comp @@ -0,0 +1,23 @@ +#version 450 + +layout( + local_size_x = 64, + local_size_y = 1, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform uimageBuffer dst; + +layout(push_constant) +uniform u_info_t { + uvec4 clear_value; + ivec4 dst_offset; + ivec4 dst_size; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID.x); + + if (thread_id.x < u_info.dst_size.x) + imageStore(dst, thread_id.x + u_info.dst_offset.x, u_info.clear_value); +} \ No newline at end of file diff --git a/src/dxvk/shaders/dxvk_clear_image1d_f.comp b/src/dxvk/shaders/dxvk_clear_image1d_f.comp new file mode 100644 index 00000000..560578b8 --- /dev/null +++ b/src/dxvk/shaders/dxvk_clear_image1d_f.comp @@ -0,0 +1,23 @@ +#version 450 + +layout( + local_size_x = 64, + local_size_y = 1, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform image1DArray dst; + +layout(push_constant) +uniform u_info_t { + vec4 clear_value; + ivec4 dst_offset; + ivec4 dst_size; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID.x); + + if (all(lessThan(thread_id.xy, u_info.dst_size.xy))) + imageStore(dst, thread_id.xy + u_info.dst_offset.xy, u_info.clear_value); +} \ No newline at end of file diff --git a/src/dxvk/shaders/dxvk_clear_image1d_u.comp b/src/dxvk/shaders/dxvk_clear_image1d_u.comp new file mode 100644 index 00000000..37b57e2f --- /dev/null +++ b/src/dxvk/shaders/dxvk_clear_image1d_u.comp @@ -0,0 +1,23 @@ +#version 450 + +layout( + local_size_x = 64, + local_size_y = 1, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform uimage1DArray dst; + +layout(push_constant) +uniform u_info_t { + uvec4 clear_value; + ivec4 dst_offset; + ivec4 dst_size; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID.x); + + if (all(lessThan(thread_id.xy, u_info.dst_size.xy))) + imageStore(dst, thread_id.xy + u_info.dst_offset.xy, u_info.clear_value); +} \ No newline at end of file diff --git a/src/dxvk/shaders/dxvk_clear_image2d_f.comp b/src/dxvk/shaders/dxvk_clear_image2d_f.comp new file mode 100644 index 00000000..dbb78d45 --- /dev/null +++ b/src/dxvk/shaders/dxvk_clear_image2d_f.comp @@ -0,0 +1,23 @@ +#version 450 + +layout( + local_size_x = 64, + local_size_y = 1, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform image2DArray dst; + +layout(push_constant) +uniform u_info_t { + vec4 clear_value; + ivec4 dst_offset; + ivec4 dst_size; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID.x); + + if (all(lessThan(thread_id.xyz, u_info.dst_size.xyz))) + imageStore(dst, thread_id.xyz + u_info.dst_offset.xyz, u_info.clear_value); +} \ No newline at end of file diff --git a/src/dxvk/shaders/dxvk_clear_image2d_u.comp b/src/dxvk/shaders/dxvk_clear_image2d_u.comp new file mode 100644 index 00000000..0b264dba --- /dev/null +++ b/src/dxvk/shaders/dxvk_clear_image2d_u.comp @@ -0,0 +1,23 @@ +#version 450 + +layout( + local_size_x = 64, + local_size_y = 1, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform uimage2DArray dst; + +layout(push_constant) +uniform u_info_t { + uvec4 clear_value; + ivec4 dst_offset; + ivec4 dst_size; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID.x); + + if (all(lessThan(thread_id.xyz, u_info.dst_size.xyz))) + imageStore(dst, thread_id.xyz + u_info.dst_offset.xyz, u_info.clear_value); +} \ No newline at end of file diff --git a/src/dxvk/shaders/dxvk_clear_image3d_f.comp b/src/dxvk/shaders/dxvk_clear_image3d_f.comp new file mode 100644 index 00000000..d5887da5 --- /dev/null +++ b/src/dxvk/shaders/dxvk_clear_image3d_f.comp @@ -0,0 +1,23 @@ +#version 450 + +layout( + local_size_x = 64, + local_size_y = 1, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform image3D dst; + +layout(push_constant) +uniform u_info_t { + vec4 clear_value; + ivec4 dst_offset; + ivec4 dst_size; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID.x); + + if (all(lessThan(thread_id.xyz, u_info.dst_size.xyz))) + imageStore(dst, thread_id.xyz + u_info.dst_offset.xyz, u_info.clear_value); +} \ No newline at end of file diff --git a/src/dxvk/shaders/dxvk_clear_image3d_u.comp b/src/dxvk/shaders/dxvk_clear_image3d_u.comp new file mode 100644 index 00000000..410b551f --- /dev/null +++ b/src/dxvk/shaders/dxvk_clear_image3d_u.comp @@ -0,0 +1,23 @@ +#version 450 + +layout( + local_size_x = 64, + local_size_y = 1, + local_size_z = 1) in; + +layout(binding = 0) +writeonly uniform uimage3D dst; + +layout(push_constant) +uniform u_info_t { + uvec4 clear_value; + ivec4 dst_offset; + ivec4 dst_size; +} u_info; + +void main() { + ivec3 thread_id = ivec3(gl_GlobalInvocationID.x); + + if (all(lessThan(thread_id.xyz, u_info.dst_size.xyz))) + imageStore(dst, thread_id.xyz + u_info.dst_offset.xyz, u_info.clear_value); +} \ No newline at end of file