shader: Implement TXQ and fix FragDepth
This commit is contained in:
parent
d9c5bd9509
commit
17063d16a3
15 changed files with 264 additions and 21 deletions
|
@ -91,7 +91,15 @@ private:
|
|||
Id Texture(EmitContext& ctx, const IR::Value& index) {
|
||||
if (index.IsImmediate()) {
|
||||
const TextureDefinition def{ctx.textures.at(index.U32())};
|
||||
return ctx.OpLoad(def.type, def.id);
|
||||
return ctx.OpLoad(def.sampled_type, def.id);
|
||||
}
|
||||
throw NotImplementedException("Indirect texture sample");
|
||||
}
|
||||
|
||||
Id TextureImage(EmitContext& ctx, const IR::Value& index) {
|
||||
if (index.IsImmediate()) {
|
||||
const TextureDefinition def{ctx.textures.at(index.U32())};
|
||||
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, def.id));
|
||||
}
|
||||
throw NotImplementedException("Indirect texture sample");
|
||||
}
|
||||
|
@ -149,6 +157,10 @@ Id EmitBindlessImageFetch(EmitContext&) {
|
|||
throw LogicError("Unreachable instruction");
|
||||
}
|
||||
|
||||
Id EmitBindlessImageQueryDimensions(EmitContext&) {
|
||||
throw LogicError("Unreachable instruction");
|
||||
}
|
||||
|
||||
Id EmitBoundImageSampleImplicitLod(EmitContext&) {
|
||||
throw LogicError("Unreachable instruction");
|
||||
}
|
||||
|
@ -177,6 +189,10 @@ Id EmitBoundImageFetch(EmitContext&) {
|
|||
throw LogicError("Unreachable instruction");
|
||||
}
|
||||
|
||||
Id EmitBoundImageQueryDimensions(EmitContext&) {
|
||||
throw LogicError("Unreachable instruction");
|
||||
}
|
||||
|
||||
Id EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
|
||||
Id bias_lc, Id offset) {
|
||||
const auto info{inst->Flags<IR::TextureInstInfo>()};
|
||||
|
@ -241,4 +257,34 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c
|
|||
Texture(ctx, index), coords, operands.Mask(), operands.Span());
|
||||
}
|
||||
|
||||
Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod) {
|
||||
const auto info{inst->Flags<IR::TextureInstInfo>()};
|
||||
const Id image{TextureImage(ctx, index)};
|
||||
const Id zero{ctx.u32_zero_value};
|
||||
const auto mips{[&] { return ctx.OpImageQueryLevels(ctx.U32[1], image); }};
|
||||
switch (info.type) {
|
||||
case TextureType::Color1D:
|
||||
case TextureType::Shadow1D:
|
||||
return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[1], image, lod),
|
||||
zero, zero, mips());
|
||||
case TextureType::ColorArray1D:
|
||||
case TextureType::Color2D:
|
||||
case TextureType::ColorCube:
|
||||
case TextureType::ShadowArray1D:
|
||||
case TextureType::Shadow2D:
|
||||
case TextureType::ShadowCube:
|
||||
return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[2], image, lod),
|
||||
zero, mips());
|
||||
case TextureType::ColorArray2D:
|
||||
case TextureType::Color3D:
|
||||
case TextureType::ColorArrayCube:
|
||||
case TextureType::ShadowArray2D:
|
||||
case TextureType::Shadow3D:
|
||||
case TextureType::ShadowArrayCube:
|
||||
return ctx.OpCompositeConstruct(ctx.U32[4], ctx.OpImageQuerySizeLod(ctx.U32[3], image, lod),
|
||||
mips());
|
||||
}
|
||||
throw LogicError("Unspecified image type {}", info.type.Value());
|
||||
}
|
||||
|
||||
} // namespace Shader::Backend::SPIRV
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue