2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

emit_glsl_image: Implement TXQ with MSAA textures

Also fixes for texture buffers, which do not have mips eithers.
This commit is contained in:
ameerj 2023-01-29 13:31:47 -05:00
parent 3aab574521
commit 08feba2b56

View file

@ -25,6 +25,13 @@ std::string Image(EmitContext& ctx, const IR::TextureInstInfo& info, const IR::V
return fmt::format("img{}{}", def.binding, index_offset); return fmt::format("img{}{}", def.binding, index_offset);
} }
bool IsTextureMsaa(EmitContext& ctx, const IR::TextureInstInfo& info) {
if (info.type == TextureType::Buffer) {
return false;
}
return ctx.info.texture_descriptors.at(info.descriptor_index).is_multisample;
}
std::string CastToIntVec(std::string_view value, const IR::TextureInstInfo& info) { std::string CastToIntVec(std::string_view value, const IR::TextureInstInfo& info) {
switch (info.type) { switch (info.type) {
case TextureType::Color1D: case TextureType::Color1D:
@ -463,26 +470,33 @@ void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value&
std::string_view lod, const IR::Value& skip_mips_val) { std::string_view lod, const IR::Value& skip_mips_val) {
const auto info{inst.Flags<IR::TextureInstInfo>()}; const auto info{inst.Flags<IR::TextureInstInfo>()};
const auto texture{Texture(ctx, info, index)}; const auto texture{Texture(ctx, info, index)};
const bool is_msaa{IsTextureMsaa(ctx, info)};
const bool skip_mips{skip_mips_val.U1()}; const bool skip_mips{skip_mips_val.U1()};
const auto mips{ const auto mips{skip_mips ? "0u" : fmt::format("uint(textureQueryLevels({}))", texture)};
[&] { return skip_mips ? "0u" : fmt::format("uint(textureQueryLevels({}))", texture); }}; if (is_msaa && !skip_mips) {
throw NotImplementedException("EmitImageQueryDimensions MSAA QueryLevels");
}
if (info.type == TextureType::Buffer && !skip_mips) {
throw NotImplementedException("EmitImageQueryDimensions TextureType::Buffer QueryLevels");
}
const bool uses_lod{!is_msaa && info.type != TextureType::Buffer};
const auto lod_str{uses_lod ? fmt::format(",int({})", lod) : ""};
switch (info.type) { switch (info.type) {
case TextureType::Color1D: case TextureType::Color1D:
return ctx.AddU32x4("{}=uvec4(uint(textureSize({},int({}))),0u,0u,{});", inst, texture, lod, return ctx.AddU32x4("{}=uvec4(uint(textureSize({}{})),0u,0u,{});", inst, texture, lod_str,
mips()); mips);
case TextureType::ColorArray1D: case TextureType::ColorArray1D:
case TextureType::Color2D: case TextureType::Color2D:
case TextureType::ColorCube: case TextureType::ColorCube:
case TextureType::Color2DRect: case TextureType::Color2DRect:
return ctx.AddU32x4("{}=uvec4(uvec2(textureSize({},int({}))),0u,{});", inst, texture, lod, return ctx.AddU32x4("{}=uvec4(uvec2(textureSize({}{})),0u,{});", inst, texture, lod_str,
mips()); mips);
case TextureType::ColorArray2D: case TextureType::ColorArray2D:
case TextureType::Color3D: case TextureType::Color3D:
case TextureType::ColorArrayCube: case TextureType::ColorArrayCube:
return ctx.AddU32x4("{}=uvec4(uvec3(textureSize({},int({}))),{});", inst, texture, lod, return ctx.AddU32x4("{}=uvec4(uvec3(textureSize({}{})),{});", inst, texture, lod_str, mips);
mips());
case TextureType::Buffer: case TextureType::Buffer:
throw NotImplementedException("EmitImageQueryDimensions Texture buffers"); return ctx.AddU32x4("{}=uvec4(uint(textureSize({})),0u,0u,{});", inst, texture, mips);
} }
throw LogicError("Unspecified image type {}", info.type.Value()); throw LogicError("Unspecified image type {}", info.type.Value());
} }