Skip to content

Commit

Permalink
Fix compiling with Godot master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Zylann committed Dec 27, 2023
1 parent 9d96b4e commit 07f99ff
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions util/godot/classes/rendering_device.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "rendering_device.h"
#include "../../dstack.h"
#include "../../profiling.h"
#include "../core/version.h"
#include "rd_sampler_state.h"
#include "rd_shader_source.h"
#include "rd_texture_format.h"
Expand Down Expand Up @@ -52,17 +53,26 @@ RID shader_create_from_spirv(RenderingDevice &rd, RDShaderSPIRV &p_spirv, String
Vector<RenderingDevice::ShaderStageSPIRVData> stage_data;
for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
RenderingDevice::ShaderStage stage = RenderingDevice::ShaderStage(i);
RenderingDevice::ShaderStageSPIRVData sd;
sd.shader_stage = stage;

String error = p_spirv.get_stage_compile_error(stage);
ERR_FAIL_COND_V_MSG(!error.is_empty(), RID(),
"Can't create a shader from an errored bytecode. Check errors in source bytecode.");
sd.spir_v = p_spirv.get_stage_bytecode(stage);
if (sd.spir_v.is_empty()) {

PackedByteArray bytecode = p_spirv.get_stage_bytecode(stage);
if (bytecode.is_empty()) {
continue;
}

RenderingDevice::ShaderStageSPIRVData sd;
sd.shader_stage = stage;
#if GODOT_VERSION_MAJOR == 4 && GODOT_VERSION_MINOR <= 2
sd.spir_v = bytecode;
#else
sd.spirv = bytecode;
#endif
stage_data.push_back(sd);
}

return rd.shader_create_from_spirv(stage_data, name);

#elif defined(ZN_GODOT_EXTENSION)
Expand Down

0 comments on commit 07f99ff

Please sign in to comment.