Skip to content

Commit

Permalink
SPIRV-Cross and glslang will compile with Griffin/MSVC targets now
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Feb 4, 2018
1 parent 2c7d674 commit 2963288
Show file tree
Hide file tree
Showing 30 changed files with 881 additions and 875 deletions.
1 change: 1 addition & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@ ifeq ($(HAVE_SPIRV_CROSS), 1)
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cfg.o
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_glsl.o
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_hlsl.o
#OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_msl.o
endif

ifeq ($(WANT_WGL), 1)
Expand Down
4 changes: 4 additions & 0 deletions Makefile.griffin
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,10 @@ ifeq ($(HAVE_GRIFFIN_CPP), 1)
OBJ += griffin/griffin_cpp.o
endif

ifeq ($(WANT_GLSLANG), 1)
OBJ += griffin/griffin_glslang.o
endif

ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
Expand Down
18 changes: 16 additions & 2 deletions deps/SPIRV-Cross/spirv_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,16 +723,30 @@ struct SPIRConstant : IVariant
{
Constant r[4];
// If != 0, this element is a specialization constant, and we should keep track of it as such.
uint32_t id[4] = {};
uint32_t id[4];
uint32_t vecsize = 1;

ConstantVector()
{
unsigned i;
for (i = 0; i < 4; i++)
id[i] = 0;
}
};

struct ConstantMatrix
{
ConstantVector c[4];
// If != 0, this column is a specialization constant, and we should keep track of it as such.
uint32_t id[4] = {};
uint32_t id[4];
uint32_t columns = 1;

ConstantMatrix()
{
unsigned i;
for (i = 0; i < 4; i++)
id[i] = 0;
}
};

inline uint32_t specialization_constant_id(uint32_t col, uint32_t row) const
Expand Down
12 changes: 6 additions & 6 deletions deps/SPIRV-Cross/spirv_cross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3368,7 +3368,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
CFG cfg(*this, entry);

// Analyze if there are parameters which need to be implicitly preserved with an "in" qualifier.
analyze_parameter_preservation(entry, cfg, handler.accessed_variables_to_block,
this->analyze_parameter_preservation(entry, cfg, handler.accessed_variables_to_block,
handler.complete_write_variables_to_block);

unordered_map<uint32_t, uint32_t> potential_loop_variables;
Expand All @@ -3393,7 +3393,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
// The continue block is dominated by the inner part of the loop, which does not make sense in high-level
// language output because it will be declared before the body,
// so we will have to lift the dominator up to the relevant loop header instead.
builder.add_block(continue_block_to_loop_header[block]);
builder.add_block(this->continue_block_to_loop_header[block]);

if (type.vecsize == 1 && type.columns == 1)
{
Expand Down Expand Up @@ -3447,7 +3447,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
// If a temporary is used in more than one block, we might have to lift continue block
// access up to loop header like we did for variables.
if (blocks.size() != 1 && this->is_continue(block))
builder.add_block(continue_block_to_loop_header[block]);
builder.add_block(this->continue_block_to_loop_header[block]);
}

uint32_t dominating_block = builder.get_dominator();
Expand All @@ -3462,10 +3462,10 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
// This should be very rare, but if we try to declare a temporary inside a loop,
// and that temporary is used outside the loop as well (spirv-opt inliner likes this)
// we should actually emit the temporary outside the loop.
hoisted_temporaries.insert(var.first);
forced_temporaries.insert(var.first);
this->hoisted_temporaries.insert(var.first);
this->forced_temporaries.insert(var.first);

auto &block_temporaries = get<SPIRBlock>(dominating_block).declare_temporary;
auto &block_temporaries = this->get<SPIRBlock>(dominating_block).declare_temporary;
block_temporaries.emplace_back(handler.result_id_to_type[var.first], var.first);
}
}
Expand Down
15 changes: 12 additions & 3 deletions deps/SPIRV-Cross/spirv_hlsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static string image_format_to_type(ImageFormat fmt, SPIRType::BaseType basetype)
}

// Returns true if an arithmetic operation does not change behavior depending on signedness.
static bool opcode_is_sign_invariant(Op opcode)
static bool hlsl_opcode_is_sign_invariant(Op opcode)
{
switch (opcode)
{
Expand Down Expand Up @@ -3054,15 +3054,24 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
auto ops = stream(instruction);
auto opcode = static_cast<Op>(instruction.op);

#undef BOP
#undef BOP_CAST
#undef UOP
#undef QFOP
#undef TFOP
#undef BFOP
#undef BFOP_CAST
#undef BFOP
#undef UFOP
#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BOP_CAST(op, type) \
emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode))
emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode))
#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op)
#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op)
#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op)
#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BFOP_CAST(op, type) \
emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode))
emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode))
#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op)
#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op)

Expand Down
8 changes: 7 additions & 1 deletion deps/SPIRV-Cross/spirv_msl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,13 @@ void CompilerMSL::emit_specialization_constants()
// Override for MSL-specific syntax instructions
void CompilerMSL::emit_instruction(const Instruction &instruction)
{

#undef BOP
#undef BOP_CAST
#undef UOP
#undef QFOP
#undef TFOP
#undef BFOP
#undef BFOP_CAST
#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BOP_CAST(op, type) \
emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
//POSSIBILITY OF SUCH DAMAGE.
//

#ifndef _MACHINE_INDEPENDENT_LIVE_TRAVERSER_H
#define _MACHINE_INDEPENDENT_LIVE_TRAVERSER_H

#include "../Include/Common.h"
#include "reflection.h"
#include "localintermediate.h"
Expand Down Expand Up @@ -134,3 +137,5 @@ class TLiveTraverser : public TIntermTraverser {
};

} // namespace glslang

#endif
Loading

0 comments on commit 2963288

Please sign in to comment.