SPIR-V: Smear one-component scalars
This commit is contained in:
parent
14a6fd838a
commit
abdf071c7d
|
@ -467,12 +467,10 @@ std::vector<uint8_t> SpirvShaderTranslator::CompleteTranslation() {
|
||||||
std::vector<Id>({b.makeUintConstant(2)}));
|
std::vector<Id>({b.makeUintConstant(2)}));
|
||||||
auto alpha_test = b.createLoad(alpha_test_ptr);
|
auto alpha_test = b.createLoad(alpha_test_ptr);
|
||||||
|
|
||||||
auto alpha_test_enabled = b.createCompositeExtract(
|
auto alpha_test_enabled =
|
||||||
alpha_test, float_type_, std::vector<uint32_t>{0});
|
b.createCompositeExtract(alpha_test, float_type_, 0);
|
||||||
auto alpha_test_func = b.createCompositeExtract(alpha_test, float_type_,
|
auto alpha_test_func = b.createCompositeExtract(alpha_test, float_type_, 1);
|
||||||
std::vector<uint32_t>{1});
|
auto alpha_test_ref = b.createCompositeExtract(alpha_test, float_type_, 2);
|
||||||
auto alpha_test_ref = b.createCompositeExtract(alpha_test, float_type_,
|
|
||||||
std::vector<uint32_t>{2});
|
|
||||||
|
|
||||||
alpha_test_func =
|
alpha_test_func =
|
||||||
b.createUnaryOp(spv::Op::OpConvertFToU, uint_type_, alpha_test_func);
|
b.createUnaryOp(spv::Op::OpConvertFToU, uint_type_, alpha_test_func);
|
||||||
|
@ -2455,6 +2453,7 @@ void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
||||||
auto n_el = b.getNumComponents(source_value_id);
|
auto n_el = b.getNumComponents(source_value_id);
|
||||||
auto n_dst = b.getNumTypeComponents(storage_type);
|
auto n_dst = b.getNumTypeComponents(storage_type);
|
||||||
|
|
||||||
|
if (n_el != 1) {
|
||||||
std::vector<uint32_t> channels;
|
std::vector<uint32_t> channels;
|
||||||
for (int i = 0; i < n_dst; i++) {
|
for (int i = 0; i < n_dst; i++) {
|
||||||
channels.push_back(i % n_el);
|
channels.push_back(i % n_el);
|
||||||
|
@ -2462,6 +2461,10 @@ void SpirvShaderTranslator::StoreToResult(Id source_value_id,
|
||||||
|
|
||||||
source_value_id = b.createRvalueSwizzle(spv::NoPrecision, storage_type,
|
source_value_id = b.createRvalueSwizzle(spv::NoPrecision, storage_type,
|
||||||
source_value_id, channels);
|
source_value_id, channels);
|
||||||
|
} else {
|
||||||
|
source_value_id =
|
||||||
|
b.smearScalar(spv::NoPrecision, source_value_id, storage_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// swizzle
|
// swizzle
|
||||||
|
|
Loading…
Reference in New Issue