Merge pull request #9652 from liamwhite/ms
spirv: fix multisampled image fetch
This commit is contained in:
commit
58ba508e9a
4 changed files with 16 additions and 2 deletions
|
@ -436,6 +436,10 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c
|
||||||
if (info.type == TextureType::Buffer) {
|
if (info.type == TextureType::Buffer) {
|
||||||
lod = Id{};
|
lod = Id{};
|
||||||
}
|
}
|
||||||
|
if (Sirit::ValidId(ms)) {
|
||||||
|
// This image is multisampled, lod must be implicit
|
||||||
|
lod = Id{};
|
||||||
|
}
|
||||||
const ImageOperands operands(offset, lod, ms);
|
const ImageOperands operands(offset, lod, ms);
|
||||||
return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4],
|
return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4],
|
||||||
TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span());
|
TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span());
|
||||||
|
|
|
@ -35,6 +35,7 @@ Id ImageType(EmitContext& ctx, const TextureDescriptor& desc) {
|
||||||
const spv::ImageFormat format{spv::ImageFormat::Unknown};
|
const spv::ImageFormat format{spv::ImageFormat::Unknown};
|
||||||
const Id type{ctx.F32[1]};
|
const Id type{ctx.F32[1]};
|
||||||
const bool depth{desc.is_depth};
|
const bool depth{desc.is_depth};
|
||||||
|
const bool ms{desc.is_multisample};
|
||||||
switch (desc.type) {
|
switch (desc.type) {
|
||||||
case TextureType::Color1D:
|
case TextureType::Color1D:
|
||||||
return ctx.TypeImage(type, spv::Dim::Dim1D, depth, false, false, 1, format);
|
return ctx.TypeImage(type, spv::Dim::Dim1D, depth, false, false, 1, format);
|
||||||
|
@ -42,9 +43,9 @@ Id ImageType(EmitContext& ctx, const TextureDescriptor& desc) {
|
||||||
return ctx.TypeImage(type, spv::Dim::Dim1D, depth, true, false, 1, format);
|
return ctx.TypeImage(type, spv::Dim::Dim1D, depth, true, false, 1, format);
|
||||||
case TextureType::Color2D:
|
case TextureType::Color2D:
|
||||||
case TextureType::Color2DRect:
|
case TextureType::Color2DRect:
|
||||||
return ctx.TypeImage(type, spv::Dim::Dim2D, depth, false, false, 1, format);
|
return ctx.TypeImage(type, spv::Dim::Dim2D, depth, false, ms, 1, format);
|
||||||
case TextureType::ColorArray2D:
|
case TextureType::ColorArray2D:
|
||||||
return ctx.TypeImage(type, spv::Dim::Dim2D, depth, true, false, 1, format);
|
return ctx.TypeImage(type, spv::Dim::Dim2D, depth, true, ms, 1, format);
|
||||||
case TextureType::Color3D:
|
case TextureType::Color3D:
|
||||||
return ctx.TypeImage(type, spv::Dim::Dim3D, depth, false, false, 1, format);
|
return ctx.TypeImage(type, spv::Dim::Dim3D, depth, false, false, 1, format);
|
||||||
case TextureType::ColorCube:
|
case TextureType::ColorCube:
|
||||||
|
|
|
@ -524,6 +524,7 @@ void TexturePass(Environment& env, IR::Program& program, const HostTranslateInfo
|
||||||
|
|
||||||
const auto& cbuf{texture_inst.cbuf};
|
const auto& cbuf{texture_inst.cbuf};
|
||||||
auto flags{inst->Flags<IR::TextureInstInfo>()};
|
auto flags{inst->Flags<IR::TextureInstInfo>()};
|
||||||
|
bool is_multisample{false};
|
||||||
switch (inst->GetOpcode()) {
|
switch (inst->GetOpcode()) {
|
||||||
case IR::Opcode::ImageQueryDimensions:
|
case IR::Opcode::ImageQueryDimensions:
|
||||||
flags.type.Assign(ReadTextureType(env, cbuf));
|
flags.type.Assign(ReadTextureType(env, cbuf));
|
||||||
|
@ -538,6 +539,12 @@ void TexturePass(Environment& env, IR::Program& program, const HostTranslateInfo
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IR::Opcode::ImageFetch:
|
case IR::Opcode::ImageFetch:
|
||||||
|
if (flags.type == TextureType::Color2D || flags.type == TextureType::Color2DRect ||
|
||||||
|
flags.type == TextureType::ColorArray2D) {
|
||||||
|
is_multisample = !inst->Arg(4).IsEmpty();
|
||||||
|
} else {
|
||||||
|
inst->SetArg(4, IR::U32{});
|
||||||
|
}
|
||||||
if (flags.type != TextureType::Color1D) {
|
if (flags.type != TextureType::Color1D) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -613,6 +620,7 @@ void TexturePass(Environment& env, IR::Program& program, const HostTranslateInfo
|
||||||
index = descriptors.Add(TextureDescriptor{
|
index = descriptors.Add(TextureDescriptor{
|
||||||
.type = flags.type,
|
.type = flags.type,
|
||||||
.is_depth = flags.is_depth != 0,
|
.is_depth = flags.is_depth != 0,
|
||||||
|
.is_multisample = is_multisample,
|
||||||
.has_secondary = cbuf.has_secondary,
|
.has_secondary = cbuf.has_secondary,
|
||||||
.cbuf_index = cbuf.index,
|
.cbuf_index = cbuf.index,
|
||||||
.cbuf_offset = cbuf.offset,
|
.cbuf_offset = cbuf.offset,
|
||||||
|
|
|
@ -109,6 +109,7 @@ using ImageBufferDescriptors = boost::container::small_vector<ImageBufferDescrip
|
||||||
struct TextureDescriptor {
|
struct TextureDescriptor {
|
||||||
TextureType type;
|
TextureType type;
|
||||||
bool is_depth;
|
bool is_depth;
|
||||||
|
bool is_multisample;
|
||||||
bool has_secondary;
|
bool has_secondary;
|
||||||
u32 cbuf_index;
|
u32 cbuf_index;
|
||||||
u32 cbuf_offset;
|
u32 cbuf_offset;
|
||||||
|
|
Loading…
Reference in a new issue