From 79142d920ed36cded3a12b80646fbbb64a0d4e37 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Mon, 11 Mar 2024 16:59:13 +0100 Subject: [PATCH] Write the execution mode for fragment shaders --- Sources/backends/spirv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/backends/spirv.c b/Sources/backends/spirv.c index 6d5a8de..24d3e27 100644 --- a/Sources/backends/spirv.c +++ b/Sources/backends/spirv.c @@ -117,6 +117,7 @@ typedef enum spirv_opcode { SPIRV_OPCODE_EXT_INST_IMPORT = 11, SPIRV_OPCODE_MEMORY_MODEL = 14, SPIRV_OPCODE_ENTRY_POINT = 15, + SPIRV_OPCODE_EXECUTION_MODE = 16, SPIRV_OPCODE_CAPABILITY = 17, SPIRV_OPCODE_TYPE_VOID = 19, SPIRV_OPCODE_TYPE_INT = 21, @@ -155,6 +156,8 @@ typedef enum storage_class { STORAGE_CLASS_INPUT = 1, STORAGE_CLASS_OUTPUT = 3, typedef enum function_control { FUNCTION_CONTROL_NONE } function_control; +typedef enum execution_mode { EXECUTION_MODE_ORIGIN_UPPER_LEFT = 7 } execution_mode; + static uint32_t operands_buffer[4096]; static void write_simple_instruction(instructions_buffer *instructions, spirv_opcode o) { @@ -238,6 +241,13 @@ static void write_op_entry_point(instructions_buffer *instructions, execution_mo write_instruction(instructions, 3 + name_length + interfaces_size, SPIRV_OPCODE_ENTRY_POINT, operands_buffer); } +static void write_op_execution_mode(instructions_buffer *instructions, uint32_t entry_point, uint32_t execution_mode) { + operands_buffer[0] = entry_point; + operands_buffer[1] = execution_mode; + + write_instruction(instructions, 3, SPIRV_OPCODE_EXECUTION_MODE, operands_buffer); +} + static void write_capabilities(instructions_buffer *instructions) { write_capability(instructions, CAPABILITY_SHADER); } @@ -962,6 +972,7 @@ static void spirv_export_fragment(char *directory, function *main) { // input_var = allocate_index(); uint32_t interfaces[] = {output_var /*, input_var*/}; write_op_entry_point(&decorations, EXECUTION_MODEL_FRAGMENT, entry_point, "main", interfaces, sizeof(interfaces) / 4); + write_op_execution_mode(&decorations, entry_point, EXECUTION_MODE_ORIGIN_UPPER_LEFT); /*uint32_t output_struct = allocate_index(); write_vertex_output_decorations(&decorations, output_struct);