mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[dxvk] Get rid of immutable sampler for resolve operations
This commit is contained in:
parent
26c8f46b6b
commit
d9466eb2b9
@ -4281,7 +4281,7 @@ namespace dxvk {
|
||||
descriptorWrites[i].dstSet = descriptorSet;
|
||||
descriptorWrites[i].dstBinding = i;
|
||||
descriptorWrites[i].descriptorCount = 1;
|
||||
descriptorWrites[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
descriptorWrites[i].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
||||
descriptorWrites[i].pImageInfo = &descriptorImages[i];
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,6 @@ namespace dxvk {
|
||||
|
||||
DxvkMetaResolveObjects::DxvkMetaResolveObjects(const DxvkDevice* device)
|
||||
: m_vkd (device->vkd()),
|
||||
m_sampler (createSampler()),
|
||||
m_shaderFragF (device->features().amdShaderFragmentMask
|
||||
? createShaderModule(dxvk_resolve_frag_f_amd)
|
||||
: createShaderModule(dxvk_resolve_frag_f)),
|
||||
@ -87,8 +86,6 @@ namespace dxvk {
|
||||
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_shaderFragU, nullptr);
|
||||
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_shaderGeom, nullptr);
|
||||
m_vkd->vkDestroyShaderModule(m_vkd->device(), m_shaderVert, nullptr);
|
||||
|
||||
m_vkd->vkDestroySampler(m_vkd->device(), m_sampler, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -115,23 +112,6 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
VkSampler DxvkMetaResolveObjects::createSampler() const {
|
||||
VkSamplerCreateInfo info = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
|
||||
info.magFilter = VK_FILTER_NEAREST;
|
||||
info.minFilter = VK_FILTER_NEAREST;
|
||||
info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
||||
info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
info.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
||||
|
||||
VkSampler result = VK_NULL_HANDLE;
|
||||
if (m_vkd->vkCreateSampler(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS)
|
||||
throw DxvkError("DxvkMetaResolveObjects: Failed to create sampler");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
VkShaderModule DxvkMetaResolveObjects::createShaderModule(
|
||||
const SpirvCodeBuffer& code) const {
|
||||
VkShaderModuleCreateInfo info = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO };
|
||||
@ -158,8 +138,8 @@ namespace dxvk {
|
||||
VkDescriptorSetLayout DxvkMetaResolveObjects::createDescriptorSetLayout(
|
||||
const DxvkMetaResolvePipelineKey& key) {
|
||||
std::array<VkDescriptorSetLayoutBinding, 2> bindings = {{
|
||||
{ 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, &m_sampler },
|
||||
{ 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, &m_sampler },
|
||||
{ 0, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr },
|
||||
{ 1, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr },
|
||||
}};
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO };
|
||||
|
@ -112,8 +112,6 @@ namespace dxvk {
|
||||
|
||||
Rc<vk::DeviceFn> m_vkd;
|
||||
|
||||
VkSampler m_sampler;
|
||||
|
||||
VkShaderModule m_shaderVert = VK_NULL_HANDLE;
|
||||
VkShaderModule m_shaderGeom = VK_NULL_HANDLE;
|
||||
VkShaderModule m_shaderFragF = VK_NULL_HANDLE;
|
||||
@ -129,8 +127,6 @@ namespace dxvk {
|
||||
DxvkMetaResolvePipeline,
|
||||
DxvkHash, DxvkEq> m_pipelines;
|
||||
|
||||
VkSampler createSampler() const;
|
||||
|
||||
VkShaderModule createShaderModule(
|
||||
const SpirvCodeBuffer& code) const;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_EXT_samplerless_texture_functions : enable
|
||||
|
||||
#define VK_RESOLVE_MODE_NONE (0)
|
||||
#define VK_RESOLVE_MODE_SAMPLE_ZERO_BIT (1 << 0)
|
||||
#define VK_RESOLVE_MODE_AVERAGE_BIT (1 << 1)
|
||||
@ -9,7 +11,7 @@
|
||||
layout(constant_id = 0) const int c_samples = 1;
|
||||
layout(constant_id = 1) const int c_mode_d = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
|
||||
|
||||
layout(binding = 0) uniform sampler2DMSArray s_depth;
|
||||
layout(binding = 0) uniform texture2DMSArray s_depth;
|
||||
|
||||
layout(push_constant)
|
||||
uniform u_info_t {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_ARB_shader_stencil_export : enable
|
||||
#extension GL_EXT_samplerless_texture_functions : enable
|
||||
|
||||
#define VK_RESOLVE_MODE_NONE (0)
|
||||
#define VK_RESOLVE_MODE_SAMPLE_ZERO_BIT (1 << 0)
|
||||
@ -12,8 +13,8 @@ layout(constant_id = 0) const int c_samples = 1;
|
||||
layout(constant_id = 1) const int c_mode_d = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
|
||||
layout(constant_id = 2) const int c_mode_s = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
|
||||
|
||||
layout(binding = 0) uniform sampler2DMSArray s_depth;
|
||||
layout(binding = 1) uniform usampler2DMSArray s_stencil;
|
||||
layout(binding = 0) uniform texture2DMSArray s_depth;
|
||||
layout(binding = 1) uniform utexture2DMSArray s_stencil;
|
||||
|
||||
layout(push_constant)
|
||||
uniform u_info_t {
|
||||
|
@ -1,8 +1,10 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_EXT_samplerless_texture_functions : enable
|
||||
|
||||
layout(constant_id = 0) const int c_samples = 1;
|
||||
|
||||
layout(binding = 0) uniform sampler2DMSArray s_image;
|
||||
layout(binding = 0) uniform texture2DMSArray s_image;
|
||||
|
||||
layout(location = 0) out vec4 o_color;
|
||||
|
||||
|
@ -1,11 +1,20 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_AMD_shader_fragment_mask: enable
|
||||
#extension GL_EXT_samplerless_texture_functions : enable
|
||||
#extension GL_EXT_spirv_intrinsics : enable
|
||||
|
||||
// GL_AMD_shader_fragment_mask was never updated to support
|
||||
// sampler-less functions, so we have to define these manually
|
||||
spirv_instruction(extensions = ["SPV_AMD_shader_fragment_mask"], capabilities = [5010], id = 5011)
|
||||
uint fragment_mask_fetch(texture2DMSArray tex, ivec3 coord);
|
||||
|
||||
spirv_instruction(extensions = ["SPV_AMD_shader_fragment_mask"], capabilities = [5010], id = 5012)
|
||||
vec4 fragment_fetch(texture2DMSArray tex, ivec3 coord, uint index);
|
||||
|
||||
layout(constant_id = 0) const int c_samples = 1;
|
||||
|
||||
layout(set = 0, binding = 0)
|
||||
uniform sampler2DMSArray s_image;
|
||||
uniform texture2DMSArray s_image;
|
||||
|
||||
layout(location = 0) out vec4 o_color;
|
||||
|
||||
@ -18,7 +27,7 @@ void main() {
|
||||
ivec3 coord = ivec3(gl_FragCoord.xy + u_info.offset, gl_Layer);
|
||||
|
||||
// get a four-bit fragment index for each sample
|
||||
uint fragMask = fragmentMaskFetchAMD(s_image, coord);
|
||||
uint fragMask = fragment_mask_fetch(s_image, coord);
|
||||
|
||||
// count number of occurences of each fragment
|
||||
// index in one four-bit counter for each sample
|
||||
@ -37,11 +46,11 @@ void main() {
|
||||
int fragIndex = findLSB(fragCount) >> 2;
|
||||
int fragShift = fragIndex << 2;
|
||||
|
||||
o_color += fragmentFetchAMD(s_image, coord, fragIndex)
|
||||
o_color += fragment_fetch(s_image, coord, fragIndex)
|
||||
* float(bitfieldExtract(fragCount, fragShift, 4));
|
||||
|
||||
fragCount = bitfieldInsert(fragCount, 0, fragShift, 4);
|
||||
}
|
||||
|
||||
o_color /= float(c_samples);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#version 450
|
||||
|
||||
layout(binding = 0) uniform isampler2DMSArray s_image;
|
||||
#extension GL_EXT_samplerless_texture_functions : enable
|
||||
|
||||
layout(binding = 0) uniform itexture2DMSArray s_image;
|
||||
|
||||
layout(location = 0) out ivec4 o_color;
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#version 450
|
||||
|
||||
layout(binding = 0) uniform usampler2DMSArray s_image;
|
||||
#extension GL_EXT_samplerless_texture_functions : enable
|
||||
|
||||
layout(binding = 0) uniform utexture2DMSArray s_image;
|
||||
|
||||
layout(location = 0) out uvec4 o_color;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user