mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-12 05:40:04 +00:00
video_core: Merge tex0 and tex_cube (#7173)
This commit is contained in:
parent
680e132318
commit
26d5727b19
8 changed files with 39 additions and 53 deletions
|
@ -10,6 +10,7 @@ using ProcTexClamp = TexturingRegs::ProcTexClamp;
|
|||
using ProcTexShift = TexturingRegs::ProcTexShift;
|
||||
using ProcTexCombiner = TexturingRegs::ProcTexCombiner;
|
||||
using ProcTexFilter = TexturingRegs::ProcTexFilter;
|
||||
using TextureType = Pica::TexturingRegs::TextureConfig::TextureType;
|
||||
|
||||
constexpr static size_t RESERVE_SIZE = 8 * 1024 * 1024;
|
||||
|
||||
|
@ -1265,7 +1266,7 @@ void FragmentModule::DefineExtensions() {
|
|||
out += "#extension GL_ARM_shader_framebuffer_fetch : enable\n";
|
||||
out += "#define destFactor gl_LastFragColorARM\n";
|
||||
} else {
|
||||
out += "#define destFactor texelFetch(color_buffer, ivec2(gl_FragCoord.xy), 0)\n";
|
||||
out += "#define destFactor texelFetch(tex_color, ivec2(gl_FragCoord.xy), 0)\n";
|
||||
use_blend_fallback = true;
|
||||
}
|
||||
}
|
||||
|
@ -1301,27 +1302,32 @@ void FragmentModule::DefineInterface() {
|
|||
}
|
||||
|
||||
void FragmentModule::DefineBindings() {
|
||||
// Uniform and texture buffers
|
||||
out += FSUniformBlockDef;
|
||||
out += "layout(binding = 3) uniform samplerBuffer texture_buffer_lut_lf;\n";
|
||||
out += "layout(binding = 4) uniform samplerBuffer texture_buffer_lut_rg;\n";
|
||||
out += "layout(binding = 5) uniform samplerBuffer texture_buffer_lut_rgba;\n\n";
|
||||
|
||||
const std::string_view texunit_set = profile.is_vulkan ? "set = 1, " : "";
|
||||
// Texture samplers
|
||||
const auto texunit_set = profile.is_vulkan ? "set = 1, " : "";
|
||||
const auto texture_type = config.texture.texture0_type.Value();
|
||||
for (u32 i = 0; i < 3; i++) {
|
||||
out += fmt::format("layout({0}binding = {1}) uniform sampler2D tex{1};\n", texunit_set, i);
|
||||
const auto sampler =
|
||||
i == 0 && texture_type == TextureType::TextureCube ? "samplerCube" : "sampler2D";
|
||||
out +=
|
||||
fmt::format("layout({0}binding = {1}) uniform {2} tex{1};\n", texunit_set, i, sampler);
|
||||
}
|
||||
|
||||
out += fmt::format("layout({}binding = 3) uniform samplerCube tex_cube;\n\n", texunit_set);
|
||||
|
||||
if (config.user.use_custom_normal && !profile.is_vulkan) {
|
||||
out += "layout(binding = 7) uniform sampler2D tex_normal;\n";
|
||||
out += "layout(binding = 6) uniform sampler2D tex_normal;\n";
|
||||
}
|
||||
if (use_blend_fallback && !profile.is_vulkan) {
|
||||
out += "layout(location = 10) uniform sampler2D color_buffer;\n";
|
||||
out += "layout(location = 7) uniform sampler2D tex_color;\n";
|
||||
}
|
||||
|
||||
// Storage images
|
||||
static constexpr std::array postfixes = {"px", "nx", "py", "ny", "pz", "nz"};
|
||||
const std::string_view shadow_set = profile.is_vulkan ? "set = 2, " : "";
|
||||
const auto shadow_set = profile.is_vulkan ? "set = 2, " : "";
|
||||
for (u32 i = 0; i < postfixes.size(); i++) {
|
||||
out += fmt::format(
|
||||
"layout({}binding = {}, r32ui) uniform readonly uimage2D shadow_texture_{};\n",
|
||||
|
@ -1591,7 +1597,7 @@ void FragmentModule::DefineTexUnitSampler(u32 texture_unit) {
|
|||
out += "return textureProj(tex0, vec3(texcoord0, texcoord0_w));";
|
||||
break;
|
||||
case TexturingRegs::TextureConfig::TextureCube:
|
||||
out += "return texture(tex_cube, vec3(texcoord0, texcoord0_w));";
|
||||
out += "return texture(tex0, vec3(texcoord0, texcoord0_w));";
|
||||
break;
|
||||
case TexturingRegs::TextureConfig::Shadow2D:
|
||||
out += "return shadowTexture(texcoord0, texcoord0_w);";
|
||||
|
|
|
@ -12,6 +12,7 @@ using Pica::LightingRegs;
|
|||
using Pica::RasterizerRegs;
|
||||
using Pica::TexturingRegs;
|
||||
using TevStageConfig = TexturingRegs::TevStageConfig;
|
||||
using TextureType = TexturingRegs::TextureConfig::TextureType;
|
||||
|
||||
constexpr u32 SPIRV_VERSION_1_3 = 0x00010300;
|
||||
|
||||
|
@ -977,7 +978,7 @@ void FragmentModule::DefineTexSampler(u32 texture_unit) {
|
|||
};
|
||||
|
||||
const auto sample_3d = [&](Id tex_id, bool projection) {
|
||||
const Id image_type = tex_id.value == tex_cube_id.value ? image_cube_id : image2d_id;
|
||||
const Id image_type = !projection ? image_cube_id : image2d_id;
|
||||
const Id sampled_image{OpLoad(TypeSampledImage(image_type), tex_id)};
|
||||
const Id texcoord0_w{OpLoad(f32_id, texcoord0_w_id)};
|
||||
const Id coord{OpCompositeConstruct(vec_ids.Get(3), OpCompositeExtract(f32_id, texcoord, 0),
|
||||
|
@ -1001,7 +1002,7 @@ void FragmentModule::DefineTexSampler(u32 texture_unit) {
|
|||
ret_val = sample_3d(tex0_id, true);
|
||||
break;
|
||||
case Pica::TexturingRegs::TextureConfig::TextureCube:
|
||||
ret_val = sample_3d(tex_cube_id, false);
|
||||
ret_val = sample_3d(tex0_id, false);
|
||||
break;
|
||||
case Pica::TexturingRegs::TextureConfig::Shadow2D:
|
||||
ret_val = SampleShadow();
|
||||
|
@ -1564,20 +1565,24 @@ void FragmentModule::DefineInterface() {
|
|||
view_id = DefineInput(vec_ids.Get(3), 7);
|
||||
color_id = DefineOutput(vec_ids.Get(4), 0);
|
||||
|
||||
// Define the texture unit samplers/uniforms
|
||||
// Define the texture unit samplers types
|
||||
image_buffer_id = TypeImage(f32_id, spv::Dim::Buffer, 0, 0, 0, 1, spv::ImageFormat::Unknown);
|
||||
image2d_id = TypeImage(f32_id, spv::Dim::Dim2D, 0, 0, 0, 1, spv::ImageFormat::Unknown);
|
||||
image_cube_id = TypeImage(f32_id, spv::Dim::Cube, 0, 0, 0, 1, spv::ImageFormat::Unknown);
|
||||
image_r32_id = TypeImage(u32_id, spv::Dim::Dim2D, 0, 0, 0, 2, spv::ImageFormat::R32ui);
|
||||
sampler_id = TypeSampler();
|
||||
|
||||
// Define lighting texture buffers
|
||||
texture_buffer_lut_lf_id = DefineUniformConst(image_buffer_id, 0, 3);
|
||||
texture_buffer_lut_rg_id = DefineUniformConst(image_buffer_id, 0, 4);
|
||||
texture_buffer_lut_rgba_id = DefineUniformConst(image_buffer_id, 0, 5);
|
||||
tex0_id = DefineUniformConst(TypeSampledImage(image2d_id), 1, 0);
|
||||
|
||||
// Define texture unit samplers
|
||||
const auto texture_type = config.texture.texture0_type.Value();
|
||||
const auto tex0_type = texture_type == TextureType::TextureCube ? image_cube_id : image2d_id;
|
||||
tex0_id = DefineUniformConst(TypeSampledImage(tex0_type), 1, 0);
|
||||
tex1_id = DefineUniformConst(TypeSampledImage(image2d_id), 1, 1);
|
||||
tex2_id = DefineUniformConst(TypeSampledImage(image2d_id), 1, 2);
|
||||
tex_cube_id = DefineUniformConst(TypeSampledImage(image_cube_id), 1, 3);
|
||||
|
||||
// Define shadow textures
|
||||
shadow_texture_px_id = DefineUniformConst(image_r32_id, 2, 0, true);
|
||||
|
|
|
@ -252,7 +252,6 @@ private:
|
|||
Id tex0_id{};
|
||||
Id tex1_id{};
|
||||
Id tex2_id{};
|
||||
Id tex_cube_id{};
|
||||
Id texture_buffer_lut_lf_id{};
|
||||
Id texture_buffer_lut_rg_id{};
|
||||
Id texture_buffer_lut_rgba_id{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue