Skip to content

Commit be8db2f

Browse files
committed
OpCopyObject and struct fix
Structs are allowed to have 0 members. Useless, but legal and therefore must be allowable. Implement OpCopyObject. Increment the version.
1 parent cde0583 commit be8db2f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "values/raytrace/shader-binding-table.hpp"
2222
#include "values/value.hpp"
2323

24-
constexpr auto VERSION = "0.9.1";
24+
constexpr auto VERSION = "0.10.0";
2525

2626
enum ReturnCode : int {
2727
OK = 0,

src/spv/inst-make.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,14 @@ bool Instruction::makeResult(DataView& data, unsigned location, Instruction::Dec
12151215
data[result_at].redefine(to_ret);
12161216
break;
12171217
}
1218+
case spv::OpCopyObject: { // 83
1219+
const Value* src = getValue(src_at, data);
1220+
Type* res_type = getType(dst_type_at, data);
1221+
Value* to_ret = res_type->construct();
1222+
to_ret->copyFrom(*src);
1223+
data[result_at].redefine(to_ret);
1224+
break;
1225+
}
12181226
case spv::OpTranspose: { // 84
12191227
Type* res_type = getType(dst_type_at, data);
12201228
Value* to_ret = res_type->construct();

src/spv/inst-read.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ void Instruction::readOp(std::vector<Instruction>& insts, uint16_t opcode, std::
196196
break;
197197
case spv::OpTypeSampledImage: // 27
198198
case spv::OpTypeRuntimeArray: // 29
199+
case spv::OpCopyObject: // 83
199200
case spv::OpTranspose: // 84
200201
case spv::OpImage: // 100
201202
case spv::OpConvertFToU: // 109
@@ -311,11 +312,15 @@ void Instruction::readOp(std::vector<Instruction>& insts, uint16_t opcode, std::
311312
to_load.push_back(Type::REF);
312313
break;
313314
case spv::OpTypeStruct: // 30
315+
// "It is valid for the structure to have no members."
314316
case spv::OpTypeFunction: // 33
315317
case spv::OpConstantComposite: // 44
316318
case spv::OpSpecConstantComposite: // 51
317-
case spv::OpFunctionCall: // 57
318319
case spv::OpCompositeConstruct: // 80
320+
optional.push_back(Type::REF);
321+
repeating = Repeat::WHOLE;
322+
break;
323+
case spv::OpFunctionCall: // 57
319324
to_load.push_back(Type::REF);
320325
optional.push_back(Type::REF);
321326
repeating = Repeat::WHOLE;

0 commit comments

Comments
 (0)