Browse Source

[vk] Added support for Stencil component type in texture handling

eds-true-adreno-fixes
CamilleLaVey 4 weeks ago
committed by Caio Oliveira
parent
commit
29c629737b
No known key found for this signature in database GPG Key ID: AAAE6C7FD4186B0C
  1. 6
      src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
  2. 3
      src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
  3. 16
      src/video_core/renderer_vulkan/vk_texture_cache.cpp

6
src/shader_recompiler/backend/spirv/emit_spirv_image.cpp

@ -204,8 +204,9 @@ Id TextureColorResultType(EmitContext& ctx, const TextureDefinition& def) {
case SamplerComponentType::Depth:
return ctx.F32[4];
case SamplerComponentType::Sint:
case SamplerComponentType::Stencil:
return ctx.S32[4];
case SamplerComponentType::Stencil:
return ctx.U32[4];
case SamplerComponentType::Uint:
return ctx.U32[4];
}
@ -218,8 +219,9 @@ Id TextureSampleResultToFloat(EmitContext& ctx, const TextureDefinition& def, Id
case SamplerComponentType::Depth:
return color;
case SamplerComponentType::Sint:
case SamplerComponentType::Stencil:
return ctx.OpConvertSToF(ctx.F32[4], color);
case SamplerComponentType::Stencil:
return ctx.OpConvertUToF(ctx.F32[4], color);
case SamplerComponentType::Uint:
return ctx.OpConvertUToF(ctx.F32[4], color);
}

3
src/shader_recompiler/backend/spirv/spirv_emit_context.cpp

@ -34,8 +34,9 @@ Id ComponentScalarType(EmitContext& ctx, SamplerComponentType component_type) {
case SamplerComponentType::Depth:
return ctx.F32[1];
case SamplerComponentType::Sint:
case SamplerComponentType::Stencil:
return ctx.S32[1];
case SamplerComponentType::Stencil:
return ctx.U32[1];
case SamplerComponentType::Uint:
return ctx.U32[1];
}

16
src/video_core/renderer_vulkan/vk_texture_cache.cpp

@ -886,6 +886,15 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched
view_formats[index_a].push_back(view_info.format);
}
}
if (VideoCore::Surface::GetFormatType(image_format) ==
VideoCore::Surface::SurfaceType::DepthStencil) {
const auto stencil_info = MaxwellToVK::SurfaceFormat(
device, FormatType::Optimal, true, PixelFormat::S8_UINT);
auto& formats = view_formats[index_a];
if (std::ranges::find(formats, stencil_info.format) == formats.end()) {
formats.push_back(stencil_info.format);
}
}
}
}
@ -2203,7 +2212,12 @@ VkImageView ImageView::StencilView() {
if (stencil_view) {
return *stencil_view;
}
const auto& info = MaxwellToVK::SurfaceFormat(*device, FormatType::Optimal, true, format);
PixelFormat view_format = format;
if (VideoCore::Surface::GetFormatType(format) ==
VideoCore::Surface::SurfaceType::DepthStencil) {
view_format = PixelFormat::S8_UINT;
}
const auto& info = MaxwellToVK::SurfaceFormat(*device, FormatType::Optimal, true, view_format);
stencil_view = MakeView(info.format, VK_IMAGE_ASPECT_STENCIL_BIT);
return *stencil_view;
}

Loading…
Cancel
Save