commit
652518ff59
|
@ -620,17 +620,27 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
||||||
uint32_t dim_idx = 0;
|
uint32_t dim_idx = 0;
|
||||||
switch (instr.dimension) {
|
switch (instr.dimension) {
|
||||||
case TextureDimension::k1D:
|
case TextureDimension::k1D:
|
||||||
|
src = b.createCompositeExtract(src, float_type_, 0);
|
||||||
dim_idx = 0;
|
dim_idx = 0;
|
||||||
break;
|
break;
|
||||||
case TextureDimension::k2D:
|
case TextureDimension::k2D: {
|
||||||
|
auto s0 = b.createCompositeExtract(src, float_type_, 0);
|
||||||
|
auto s1 = b.createCompositeExtract(src, float_type_, 1);
|
||||||
|
src = b.createCompositeConstruct(vec2_float_type_,
|
||||||
|
std::vector<Id>({s0, s1}));
|
||||||
dim_idx = 1;
|
dim_idx = 1;
|
||||||
break;
|
} break;
|
||||||
case TextureDimension::k3D:
|
case TextureDimension::k3D: {
|
||||||
|
auto s0 = b.createCompositeExtract(src, float_type_, 0);
|
||||||
|
auto s1 = b.createCompositeExtract(src, float_type_, 1);
|
||||||
|
auto s2 = b.createCompositeExtract(src, float_type_, 2);
|
||||||
|
src = b.createCompositeConstruct(vec3_float_type_,
|
||||||
|
std::vector<Id>({s0, s1, s2}));
|
||||||
dim_idx = 2;
|
dim_idx = 2;
|
||||||
break;
|
} break;
|
||||||
case TextureDimension::kCube:
|
case TextureDimension::kCube: {
|
||||||
dim_idx = 3;
|
dim_idx = 3;
|
||||||
break;
|
} break;
|
||||||
default:
|
default:
|
||||||
assert_unhandled_case(instr.dimension);
|
assert_unhandled_case(instr.dimension);
|
||||||
}
|
}
|
||||||
|
@ -638,19 +648,24 @@ void SpirvShaderTranslator::ProcessTextureFetchInstruction(
|
||||||
switch (instr.opcode) {
|
switch (instr.opcode) {
|
||||||
case FetchOpcode::kTextureFetch: {
|
case FetchOpcode::kTextureFetch: {
|
||||||
auto image_index = b.makeUintConstant(instr.operands[1].storage_index);
|
auto image_index = b.makeUintConstant(instr.operands[1].storage_index);
|
||||||
auto image_ptr =
|
auto image_ptr = b.createAccessChain(
|
||||||
b.createAccessChain(spv::StorageClass::StorageClassUniformConstant,
|
spv::StorageClass::StorageClassUniformConstant, img_[dim_idx],
|
||||||
img_[dim_idx], std::vector<Id>({image_index}));
|
std::vector<Id>({b.makeUintConstant(0), image_index}));
|
||||||
auto sampler_ptr =
|
auto sampler_ptr = b.createAccessChain(
|
||||||
b.createAccessChain(spv::StorageClass::StorageClassUniformConstant,
|
spv::StorageClass::StorageClassUniformConstant, samplers_,
|
||||||
samplers_, std::vector<Id>({image_index}));
|
std::vector<Id>({b.makeUintConstant(0), image_index}));
|
||||||
auto image = b.createLoad(image_ptr);
|
auto image = b.createLoad(image_ptr);
|
||||||
auto sampler = b.createLoad(sampler_ptr);
|
auto sampler = b.createLoad(sampler_ptr);
|
||||||
|
|
||||||
auto tex = b.createBinOp(spv::Op::OpSampledImage, b.getImageType(image),
|
auto tex = b.createBinOp(spv::Op::OpSampledImage, b.getImageType(image),
|
||||||
image, sampler);
|
image, sampler);
|
||||||
dest = b.createBinOp(spv::Op::OpImageSampleImplicitLod, vec4_float_type_,
|
|
||||||
tex, src);
|
spv::Builder::TextureParameters params = {0};
|
||||||
|
params.coords = src;
|
||||||
|
params.sampler = sampler;
|
||||||
|
dest = b.createTextureCall(spv::Decoration::DecorationInvariant,
|
||||||
|
vec4_float_type_, false, false, false, false,
|
||||||
|
false, params);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
// TODO: the rest of these
|
// TODO: the rest of these
|
||||||
|
|
Loading…
Reference in New Issue