mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
parent
81ec2aaa0e
commit
597631b693
@ -140,6 +140,12 @@ ConstantFoldingRule FoldInsertWithConstants() {
|
|||||||
// Work down hierarchy and add all the indexes, not including the final
|
// Work down hierarchy and add all the indexes, not including the final
|
||||||
// index.
|
// index.
|
||||||
for (uint32_t i = 2; i < inst->NumInOperands(); ++i) {
|
for (uint32_t i = 2; i < inst->NumInOperands(); ++i) {
|
||||||
|
if (composite->AsNullConstant()) {
|
||||||
|
// Return Null for the return type.
|
||||||
|
analysis::TypeManager* type_mgr = context->get_type_mgr();
|
||||||
|
return const_mgr->GetConstant(type_mgr->GetType(inst->type_id()), {});
|
||||||
|
}
|
||||||
|
|
||||||
if (i != inst->NumInOperands() - 1) {
|
if (i != inst->NumInOperands() - 1) {
|
||||||
chain.push_back(composite);
|
chain.push_back(composite);
|
||||||
}
|
}
|
||||||
|
@ -374,6 +374,33 @@ TEST_F(FoldSpecConstantOpAndCompositePassBasicTest, CompositeInsertMatrix) {
|
|||||||
SinglePassRunAndMatch<FoldSpecConstantOpAndCompositePass>(test, false);
|
SinglePassRunAndMatch<FoldSpecConstantOpAndCompositePass>(test, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FoldSpecConstantOpAndCompositePassBasicTest, CompositeInsertNull) {
|
||||||
|
const std::string test =
|
||||||
|
R"(
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint GLCompute %1 "main"
|
||||||
|
OpExecutionMode %1 LocalSize 1 1 1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v2float = OpTypeVector %float 2
|
||||||
|
%mat2v2float = OpTypeMatrix %v2float 2
|
||||||
|
%null = OpConstantNull %mat2v2float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%v2float_1 = OpConstantComposite %v2float %float_1 %float_1
|
||||||
|
%mat2v2_1 = OpConstantComposite %mat2v2float %v2float_1 %v2float_1
|
||||||
|
; CHECK: %13 = OpConstantNull %mat2v2float
|
||||||
|
%14 = OpSpecConstantOp %mat2v2float CompositeInsert %mat2v2_1 %null 0 0
|
||||||
|
%1 = OpFunction %void None %3
|
||||||
|
%16 = OpLabel
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
)";
|
||||||
|
|
||||||
|
SinglePassRunAndMatch<FoldSpecConstantOpAndCompositePass>(test, false);
|
||||||
|
}
|
||||||
|
|
||||||
// All types and some common constants that are potentially required in
|
// All types and some common constants that are potentially required in
|
||||||
// FoldSpecConstantOpAndCompositeTest.
|
// FoldSpecConstantOpAndCompositeTest.
|
||||||
std::vector<std::string> CommonTypesAndConstants() {
|
std::vector<std::string> CommonTypesAndConstants() {
|
||||||
|
Loading…
Reference in New Issue
Block a user