Allow SPIR-V when using Shadow2D texture mapping (#1057)

This commit is contained in:
PabloMK7 2025-05-24 00:05:16 +02:00 committed by GitHub
parent ee63706887
commit bf587885cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 7 deletions

View File

@ -440,7 +440,7 @@ void PipelineCache::UseFragmentShader(const Pica::RegsInternal& regs,
if (new_shader) {
workers.QueueWork([fs_config, this, &shader]() {
const bool use_spirv = Settings::values.spirv_shader_gen.GetValue();
if (use_spirv && !fs_config.UsesShadowPipeline()) {
if (use_spirv && !fs_config.UsesSpirvIncompatibleConfig()) {
const std::vector code = SPIRV::GenerateFragmentShader(fs_config, profile);
shader.module = CompileSPV(code, instance.GetDevice());
} else {

View File

@ -1,4 +1,4 @@
// Copyright 2023 Citra Emulator Project
// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -174,10 +174,9 @@ struct FSConfig {
framebuffer.alpha_blend.eq != Pica::FramebufferRegs::BlendEquation::Add;
}
[[nodiscard]] bool UsesShadowPipeline() const {
[[nodiscard]] bool UsesSpirvIncompatibleConfig() const {
const auto texture0_type = texture.texture0_type.Value();
return texture0_type == Pica::TexturingRegs::TextureConfig::Shadow2D ||
texture0_type == Pica::TexturingRegs::TextureConfig::ShadowCube ||
return texture0_type == Pica::TexturingRegs::TextureConfig::ShadowCube ||
framebuffer.shadow_rendering.Value();
}

View File

@ -1,4 +1,4 @@
// Copyright 2023 Citra Emulator Project
// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -755,8 +755,12 @@ Id FragmentModule::CompareShadow(Id pixel, Id z) {
}
Id FragmentModule::SampleShadow() {
const Id texcoord0{OpLoad(vec_ids.Get(2), texcoord_id[0])};
Id texcoord0{OpLoad(vec_ids.Get(2), texcoord_id[0])};
const Id texcoord0_w{OpLoad(f32_id, texcoord0_w_id)};
if (!config.texture.shadow_texture_orthographic) {
const Id div{OpCompositeConstruct(vec_ids.Get(2), texcoord0_w, texcoord0_w)};
texcoord0 = OpFDiv(vec_ids.Get(2), texcoord0, div);
}
const Id abs_min_w{OpFMul(f32_id, OpFMin(f32_id, OpFAbs(f32_id, texcoord0_w), ConstF32(1.f)),
ConstF32(16777215.f))};
const Id shadow_texture_bias{GetShaderDataMember(i32_id, ConstS32(17))};