spv_fs_shader_gen: Remove OpTypeSampledImage from texture buffers (#7153)
This commit is contained in:
parent
168f168c33
commit
d5b50a9fc0
|
@ -172,11 +172,9 @@ void FragmentModule::WriteFog() {
|
|||
const Id fog_lut_offset{GetShaderDataMember(i32_id, ConstS32(10))};
|
||||
const Id coord{OpIAdd(i32_id, OpConvertFToS(i32_id, fog_i), fog_lut_offset)};
|
||||
if (!Sirit::ValidId(texture_buffer_lut_lf)) {
|
||||
const Id sampled_image{TypeSampledImage(image_buffer_id)};
|
||||
texture_buffer_lut_lf = OpLoad(sampled_image, texture_buffer_lut_lf_id);
|
||||
texture_buffer_lut_lf = OpLoad(image_buffer_id, texture_buffer_lut_lf_id);
|
||||
}
|
||||
const Id fog_lut_entry_rgba{
|
||||
OpImageFetch(vec_ids.Get(4), OpImage(image_buffer_id, texture_buffer_lut_lf), coord)};
|
||||
const Id fog_lut_entry_rgba{OpImageFetch(vec_ids.Get(4), texture_buffer_lut_lf, coord)};
|
||||
const Id fog_lut_r{OpCompositeExtract(f32_id, fog_lut_entry_rgba, 0)};
|
||||
const Id fog_lut_g{OpCompositeExtract(f32_id, fog_lut_entry_rgba, 1)};
|
||||
Id fog_factor{OpFma(f32_id, fog_f, fog_lut_g, fog_lut_r)};
|
||||
|
@ -1152,11 +1150,9 @@ Id FragmentModule::ProcTexLookupLUT(Id offset, Id coord) {
|
|||
const Id index_f{OpFSub(f32_id, coord, index_i)};
|
||||
const Id p{OpIAdd(i32_id, OpConvertFToS(i32_id, index_i), offset)};
|
||||
if (!Sirit::ValidId(texture_buffer_lut_rg)) {
|
||||
const Id sampled_image{TypeSampledImage(image_buffer_id)};
|
||||
texture_buffer_lut_rg = OpLoad(sampled_image, texture_buffer_lut_rg_id);
|
||||
texture_buffer_lut_rg = OpLoad(image_buffer_id, texture_buffer_lut_rg_id);
|
||||
}
|
||||
const Id entry{
|
||||
OpImageFetch(vec_ids.Get(4), OpImage(image_buffer_id, texture_buffer_lut_rg), p)};
|
||||
const Id entry{OpImageFetch(vec_ids.Get(4), texture_buffer_lut_rg, p)};
|
||||
const Id entry_r{OpCompositeExtract(f32_id, entry, 0)};
|
||||
const Id entry_g{OpCompositeExtract(f32_id, entry, 1)};
|
||||
return OpFClamp(f32_id, OpFma(f32_id, entry_g, index_f, entry_r), ConstF32(0.f), ConstF32(1.f));
|
||||
|
@ -1234,12 +1230,10 @@ Id FragmentModule::SampleProcTexColor(Id lut_coord, Id level) {
|
|||
OpFMul(f32_id, lut_coord, OpConvertSToF(f32_id, OpISub(i32_id, lut_width, ConstS32(1))));
|
||||
|
||||
if (!Sirit::ValidId(texture_buffer_lut_rgba)) {
|
||||
const Id sampled_image{TypeSampledImage(image_buffer_id)};
|
||||
texture_buffer_lut_rgba = OpLoad(sampled_image, texture_buffer_lut_rgba_id);
|
||||
texture_buffer_lut_rgba = OpLoad(image_buffer_id, texture_buffer_lut_rgba_id);
|
||||
}
|
||||
|
||||
const Id proctex_lut_offset{GetShaderDataMember(i32_id, ConstS32(14))};
|
||||
const Id lut_rgba{OpImage(image_buffer_id, texture_buffer_lut_rgba)};
|
||||
|
||||
switch (config.proctex.lut_filter) {
|
||||
case ProcTexFilter::Linear:
|
||||
|
@ -1250,8 +1244,8 @@ Id FragmentModule::SampleProcTexColor(Id lut_coord, Id level) {
|
|||
const Id proctex_diff_lut_offset{GetShaderDataMember(i32_id, ConstS32(15))};
|
||||
const Id p1{OpIAdd(i32_id, lut_index_i, proctex_lut_offset)};
|
||||
const Id p2{OpIAdd(i32_id, lut_index_i, proctex_diff_lut_offset)};
|
||||
const Id texel1{OpImageFetch(vec_ids.Get(4), lut_rgba, p1)};
|
||||
const Id texel2{OpImageFetch(vec_ids.Get(4), lut_rgba, p2)};
|
||||
const Id texel1{OpImageFetch(vec_ids.Get(4), texture_buffer_lut_rgba, p1)};
|
||||
const Id texel2{OpImageFetch(vec_ids.Get(4), texture_buffer_lut_rgba, p2)};
|
||||
return OpFAdd(vec_ids.Get(4), texel1,
|
||||
OpVectorTimesScalar(vec_ids.Get(4), texel2, lut_index_f));
|
||||
}
|
||||
|
@ -1261,7 +1255,7 @@ Id FragmentModule::SampleProcTexColor(Id lut_coord, Id level) {
|
|||
lut_coord = OpFAdd(f32_id, lut_coord, OpConvertSToF(f32_id, lut_offset));
|
||||
const Id lut_coord_rounded{OpConvertFToS(i32_id, OpRound(f32_id, lut_coord))};
|
||||
const Id p{OpIAdd(i32_id, lut_coord_rounded, proctex_lut_offset)};
|
||||
return OpImageFetch(vec_ids.Get(4), lut_rgba, p);
|
||||
return OpImageFetch(vec_ids.Get(4), texture_buffer_lut_rgba, p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1271,16 +1265,14 @@ Id FragmentModule::SampleProcTexColor(Id lut_coord, Id level) {
|
|||
Id FragmentModule::LookupLightingLUT(Id lut_index, Id index, Id delta) {
|
||||
// Only load the texture buffer lut once
|
||||
if (!Sirit::ValidId(texture_buffer_lut_lf)) {
|
||||
const Id sampled_image{TypeSampledImage(image_buffer_id)};
|
||||
texture_buffer_lut_lf = OpLoad(sampled_image, texture_buffer_lut_lf_id);
|
||||
texture_buffer_lut_lf = OpLoad(image_buffer_id, texture_buffer_lut_lf_id);
|
||||
}
|
||||
|
||||
const Id lut_index_x{OpShiftRightArithmetic(i32_id, lut_index, ConstS32(2))};
|
||||
const Id lut_index_y{OpBitwiseAnd(i32_id, lut_index, ConstS32(3))};
|
||||
const Id lut_offset{GetShaderDataMember(i32_id, ConstS32(18), lut_index_x, lut_index_y)};
|
||||
const Id coord{OpIAdd(i32_id, lut_offset, index)};
|
||||
const Id entry{
|
||||
OpImageFetch(vec_ids.Get(4), OpImage(image_buffer_id, texture_buffer_lut_lf), coord)};
|
||||
const Id entry{OpImageFetch(vec_ids.Get(4), texture_buffer_lut_lf, coord)};
|
||||
const Id entry_r{OpCompositeExtract(f32_id, entry, 0)};
|
||||
const Id entry_g{OpCompositeExtract(f32_id, entry, 1)};
|
||||
return OpFma(f32_id, entry_g, delta, entry_r);
|
||||
|
@ -1579,9 +1571,9 @@ void FragmentModule::DefineInterface() {
|
|||
image_r32_id = TypeImage(u32_id, spv::Dim::Dim2D, 0, 0, 0, 2, spv::ImageFormat::R32ui);
|
||||
sampler_id = TypeSampler();
|
||||
|
||||
texture_buffer_lut_lf_id = DefineUniformConst(TypeSampledImage(image_buffer_id), 0, 3);
|
||||
texture_buffer_lut_rg_id = DefineUniformConst(TypeSampledImage(image_buffer_id), 0, 4);
|
||||
texture_buffer_lut_rgba_id = DefineUniformConst(TypeSampledImage(image_buffer_id), 0, 5);
|
||||
texture_buffer_lut_lf_id = DefineUniformConst(image_buffer_id, 0, 3);
|
||||
texture_buffer_lut_rg_id = DefineUniformConst(image_buffer_id, 0, 4);
|
||||
texture_buffer_lut_rgba_id = DefineUniformConst(image_buffer_id, 0, 5);
|
||||
tex0_id = DefineUniformConst(TypeSampledImage(image2d_id), 1, 0);
|
||||
tex1_id = DefineUniformConst(TypeSampledImage(image2d_id), 1, 1);
|
||||
tex2_id = DefineUniformConst(TypeSampledImage(image2d_id), 1, 2);
|
||||
|
|
Loading…
Reference in a new issue