mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-09-12 12:27:45 +02:00
glasm: Implement TXQ and improve texture info reads
This commit is contained in:
parent
c560bf99c2
commit
0a42277a4f
@ -40,52 +40,51 @@ struct ScopedRegister {
|
|||||||
Register reg;
|
Register reg;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string Texture([[maybe_unused]] EmitContext& ctx, IR::TextureInstInfo info,
|
std::string Texture(EmitContext& ctx, IR::TextureInstInfo info,
|
||||||
[[maybe_unused]] const IR::Value& index) {
|
[[maybe_unused]] const IR::Value& index) {
|
||||||
// FIXME
|
// FIXME: indexed reads
|
||||||
return fmt::format("texture[{}]", info.descriptor_index);
|
return fmt::format("texture[{}]", ctx.texture_bindings.at(info.descriptor_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view TextureType(IR::TextureInstInfo info) {
|
std::string_view TextureType(IR::TextureInstInfo info) {
|
||||||
switch (info.type) {
|
if (info.is_depth) {
|
||||||
case TextureType::Color1D:
|
switch (info.type) {
|
||||||
return "1D";
|
case TextureType::Color1D:
|
||||||
case TextureType::ColorArray1D:
|
return "SHADOW1D";
|
||||||
return "ARRAY1D";
|
case TextureType::ColorArray1D:
|
||||||
case TextureType::Color2D:
|
return "SHADOWARRAY1D";
|
||||||
return "2D";
|
case TextureType::Color2D:
|
||||||
case TextureType::ColorArray2D:
|
return "SHADOW2D";
|
||||||
return "ARRAY2D";
|
case TextureType::ColorArray2D:
|
||||||
case TextureType::Color3D:
|
return "SHADOWARRAY2D";
|
||||||
return "3D";
|
case TextureType::Color3D:
|
||||||
case TextureType::ColorCube:
|
return "SHADOW3D";
|
||||||
return "CUBE";
|
case TextureType::ColorCube:
|
||||||
case TextureType::ColorArrayCube:
|
return "SHADOWCUBE";
|
||||||
return "ARRAYCUBE";
|
case TextureType::ColorArrayCube:
|
||||||
case TextureType::Buffer:
|
return "SHADOWARRAYCUBE";
|
||||||
return "BUFFER";
|
case TextureType::Buffer:
|
||||||
}
|
return "SHADOWBUFFER";
|
||||||
throw InvalidArgument("Invalid texture type {}", info.type.Value());
|
}
|
||||||
}
|
} else {
|
||||||
|
switch (info.type) {
|
||||||
std::string_view ShadowTextureType(IR::TextureInstInfo info) {
|
case TextureType::Color1D:
|
||||||
switch (info.type) {
|
return "1D";
|
||||||
case TextureType::Color1D:
|
case TextureType::ColorArray1D:
|
||||||
return "SHADOW1D";
|
return "ARRAY1D";
|
||||||
case TextureType::ColorArray1D:
|
case TextureType::Color2D:
|
||||||
return "SHADOWARRAY1D";
|
return "2D";
|
||||||
case TextureType::Color2D:
|
case TextureType::ColorArray2D:
|
||||||
return "SHADOW2D";
|
return "ARRAY2D";
|
||||||
case TextureType::ColorArray2D:
|
case TextureType::Color3D:
|
||||||
return "SHADOWARRAY2D";
|
return "3D";
|
||||||
case TextureType::Color3D:
|
case TextureType::ColorCube:
|
||||||
return "SHADOW3D";
|
return "CUBE";
|
||||||
case TextureType::ColorCube:
|
case TextureType::ColorArrayCube:
|
||||||
return "SHADOWCUBE";
|
return "ARRAYCUBE";
|
||||||
case TextureType::ColorArrayCube:
|
case TextureType::Buffer:
|
||||||
return "SHADOWARRAYCUBE";
|
return "BUFFER";
|
||||||
case TextureType::Buffer:
|
}
|
||||||
return "SHADOWBUFFER";
|
|
||||||
}
|
}
|
||||||
throw InvalidArgument("Invalid texture type {}", info.type.Value());
|
throw InvalidArgument("Invalid texture type {}", info.type.Value());
|
||||||
}
|
}
|
||||||
@ -217,7 +216,7 @@ void EmitImageSampleDrefImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::
|
|||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
|
const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
|
||||||
const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
|
const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
|
||||||
const std::string_view type{ShadowTextureType(info)};
|
const std::string_view type{TextureType(info)};
|
||||||
const std::string texture{Texture(ctx, info, index)};
|
const std::string texture{Texture(ctx, info, index)};
|
||||||
const std::string offset_vec{Offset(ctx, offset)};
|
const std::string offset_vec{Offset(ctx, offset)};
|
||||||
const auto [coord_vec, coord_alloc]{Coord(ctx, coord)};
|
const auto [coord_vec, coord_alloc]{Coord(ctx, coord)};
|
||||||
@ -319,7 +318,7 @@ void EmitImageSampleDrefExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::
|
|||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
|
const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
|
||||||
const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
|
const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
|
||||||
const std::string_view type{ShadowTextureType(info)};
|
const std::string_view type{TextureType(info)};
|
||||||
const std::string texture{Texture(ctx, info, index)};
|
const std::string texture{Texture(ctx, info, index)};
|
||||||
const std::string offset_vec{Offset(ctx, offset)};
|
const std::string offset_vec{Offset(ctx, offset)};
|
||||||
const auto [coord_vec, coord_alloc]{Coord(ctx, coord)};
|
const auto [coord_vec, coord_alloc]{Coord(ctx, coord)};
|
||||||
@ -389,7 +388,7 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde
|
|||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
|
const auto sparse_inst{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp)};
|
||||||
const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
|
const std::string_view sparse_mod{sparse_inst ? ".SPARSE" : ""};
|
||||||
const std::string_view type{ShadowTextureType(info)};
|
const std::string_view type{TextureType(info)};
|
||||||
const std::string texture{Texture(ctx, info, index)};
|
const std::string texture{Texture(ctx, info, index)};
|
||||||
const Register coord_vec{ctx.reg_alloc.Consume(coord)};
|
const Register coord_vec{ctx.reg_alloc.Consume(coord)};
|
||||||
const ScalarF32 dref_value{ctx.reg_alloc.Consume(dref)};
|
const ScalarF32 dref_value{ctx.reg_alloc.Consume(dref)};
|
||||||
@ -429,10 +428,12 @@ void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst
|
|||||||
throw NotImplementedException("GLASM instruction");
|
throw NotImplementedException("GLASM instruction");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
||||||
[[maybe_unused]] const IR::Value& index,
|
ScalarF32 lod) {
|
||||||
[[maybe_unused]] Register lod) {
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
throw NotImplementedException("GLASM instruction");
|
const std::string texture{Texture(ctx, info, index)};
|
||||||
|
const std::string_view type{TextureType(info)};
|
||||||
|
ctx.Add("TXQ {},{},{},{};", inst, lod, texture, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
|
@ -543,7 +543,7 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde
|
|||||||
void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
|
void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
|
||||||
Register offset, Register lod, Register ms);
|
Register offset, Register lod, Register ms);
|
||||||
void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
||||||
Register lod);
|
ScalarF32 lod);
|
||||||
void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord);
|
void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord);
|
||||||
void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
|
void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, Register coord,
|
||||||
Register derivates, Register offset, Register lod_clamp);
|
Register derivates, Register offset, Register lod_clamp);
|
||||||
|
Loading…
Reference in New Issue
Block a user