|
|
@ -221,12 +221,17 @@ private: |
|
|
Id Texture(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR::Value& index) { |
|
|
Id Texture(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR::Value& index) { |
|
|
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)}; |
|
|
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)}; |
|
|
if (def.count > 1) { |
|
|
if (def.count > 1) { |
|
|
const DescriptorIndex idx{ctx, index}; |
|
|
|
|
|
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())}; |
|
|
|
|
|
idx.Decorate(ctx, pointer); |
|
|
|
|
|
const Id object{ctx.OpLoad(def.sampled_type, pointer)}; |
|
|
|
|
|
idx.Decorate(ctx, object); |
|
|
|
|
|
return object; |
|
|
|
|
|
|
|
|
if (Settings::values.legacy_descriptor_indices.GetValue()) { |
|
|
|
|
|
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, ctx.Def(index))}; |
|
|
|
|
|
return ctx.OpLoad(def.sampled_type, pointer); |
|
|
|
|
|
} else { |
|
|
|
|
|
const DescriptorIndex idx{ctx, index}; |
|
|
|
|
|
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())}; |
|
|
|
|
|
idx.Decorate(ctx, pointer); |
|
|
|
|
|
const Id object{ctx.OpLoad(def.sampled_type, pointer)}; |
|
|
|
|
|
idx.Decorate(ctx, object); |
|
|
|
|
|
return object; |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
return ctx.OpLoad(def.sampled_type, def.id); |
|
|
return ctx.OpLoad(def.sampled_type, def.id); |
|
|
} |
|
|
} |
|
|
@ -244,14 +249,20 @@ Id TextureImage(EmitContext& ctx, IR::TextureInstInfo info, const IR::Value& ind |
|
|
} else { |
|
|
} else { |
|
|
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)}; |
|
|
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)}; |
|
|
if (def.count > 1) { |
|
|
if (def.count > 1) { |
|
|
const DescriptorIndex idx{ctx, index}; |
|
|
|
|
|
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())}; |
|
|
|
|
|
idx.Decorate(ctx, ptr); |
|
|
|
|
|
const Id object{ctx.OpLoad(def.sampled_type, ptr)}; |
|
|
|
|
|
idx.Decorate(ctx, object); |
|
|
|
|
|
const Id image{ctx.OpImage(def.image_type, object)}; |
|
|
|
|
|
idx.Decorate(ctx, image); |
|
|
|
|
|
return image; |
|
|
|
|
|
|
|
|
if (Settings::values.legacy_descriptor_indices.GetValue()) { |
|
|
|
|
|
const Id idx{index.IsImmediate() ? ctx.Const(index.U32()) : ctx.Def(index)}; |
|
|
|
|
|
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx)}; |
|
|
|
|
|
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, ptr)); |
|
|
|
|
|
} else { |
|
|
|
|
|
const DescriptorIndex idx{ctx, index}; |
|
|
|
|
|
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())}; |
|
|
|
|
|
idx.Decorate(ctx, ptr); |
|
|
|
|
|
const Id object{ctx.OpLoad(def.sampled_type, ptr)}; |
|
|
|
|
|
idx.Decorate(ctx, object); |
|
|
|
|
|
const Id image{ctx.OpImage(def.image_type, object)}; |
|
|
|
|
|
idx.Decorate(ctx, image); |
|
|
|
|
|
return image; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, def.id)); |
|
|
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, def.id)); |
|
|
} |
|
|
} |
|
|
|