From ff62f402dab4838ba3df8ba1f946dc7b341ef77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 29 Jun 2023 21:10:08 +0200 Subject: [PATCH] EEVEE-Next: Fix overlap with nodetree UBO Reserve the slot 0 for nodetree and bind directly to it in Next engines. --- .../draw/engines/eevee_next/eevee_defines.hh | 15 ++++++++------- .../shaders/infos/eevee_material_info.hh | 5 ++++- source/blender/draw/intern/draw_pass.hh | 2 +- source/blender/gpu/GPU_uniform_buffer.h | 1 + source/blender/gpu/intern/gpu_codegen.cc | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/eevee_defines.hh b/source/blender/draw/engines/eevee_next/eevee_defines.hh index 69d96780ace..6017a8f560c 100644 --- a/source/blender/draw/engines/eevee_next/eevee_defines.hh +++ b/source/blender/draw/engines/eevee_next/eevee_defines.hh @@ -120,15 +120,16 @@ #define GBUF_COLOR_SLOT 4 /* Uniform Buffers. */ -#define CAMERA_BUF_SLOT 0 -#define RBUFS_BUF_SLOT 1 +/* Slot 0 is GPU_NODE_TREE_UBO_SLOT. */ +#define CAMERA_BUF_SLOT 1 +#define RBUFS_BUF_SLOT 2 /* Only during surface shading (forward and deferred eval). */ -#define HIZ_BUF_SLOT 2 -#define IRRADIANCE_GRID_BUF_SLOT 3 +#define HIZ_BUF_SLOT 3 +#define IRRADIANCE_GRID_BUF_SLOT 4 /* Only during pre-pass. */ -#define VELOCITY_CAMERA_PREV_BUF 2 -#define VELOCITY_CAMERA_CURR_BUF 3 -#define VELOCITY_CAMERA_NEXT_BUF 4 +#define VELOCITY_CAMERA_PREV_BUF 3 +#define VELOCITY_CAMERA_CURR_BUF 4 +#define VELOCITY_CAMERA_NEXT_BUF 5 /* Storage Buffers. */ #define LIGHT_CULL_BUF_SLOT 0 diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh index c90e7f4a309..532ff4d4c4a 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh @@ -208,7 +208,10 @@ GPU_SHADER_CREATE_INFO(eevee_volume_deferred) #ifdef DEBUG /* Stub functions defined by the material evaluation. */ -GPU_SHADER_CREATE_INFO(eevee_material_stub).define("EEVEE_MATERIAL_STUBS"); +GPU_SHADER_CREATE_INFO(eevee_material_stub) + .define("EEVEE_MATERIAL_STUBS") + /* Dummy uniform buffer to detect overlap with material node-tree. */ + .uniform_buf(0, "int", "node_tree"); # define EEVEE_MAT_FINAL_VARIATION(name, ...) \ GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true); diff --git a/source/blender/draw/intern/draw_pass.hh b/source/blender/draw/intern/draw_pass.hh index a2c59d2eec4..3e7bba213a8 100644 --- a/source/blender/draw/intern/draw_pass.hh +++ b/source/blender/draw/intern/draw_pass.hh @@ -857,7 +857,7 @@ template inline void PassBase::material_set(Manager &manager, GPUMat GPUUniformBuf *ubo = GPU_material_uniform_buffer_get(material); if (ubo != nullptr) { - bind_ubo(GPU_UBO_BLOCK_NAME, ubo); + bind_ubo(GPU_NODE_TREE_UBO_SLOT, ubo); } } diff --git a/source/blender/gpu/GPU_uniform_buffer.h b/source/blender/gpu/GPU_uniform_buffer.h index b13be231788..fb61a8e160e 100644 --- a/source/blender/gpu/GPU_uniform_buffer.h +++ b/source/blender/gpu/GPU_uniform_buffer.h @@ -49,6 +49,7 @@ void GPU_uniformbuf_clear_to_zero(GPUUniformBuf *ubo); #define GPU_UBO_BLOCK_NAME "node_tree" #define GPU_ATTRIBUTE_UBO_BLOCK_NAME "unf_attrs" #define GPU_LAYER_ATTRIBUTE_UBO_BLOCK_NAME "drw_layer_attrs" +#define GPU_NODE_TREE_UBO_SLOT 0 #ifdef __cplusplus } diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 8b662ed06f3..a2cab889f7a 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -459,7 +459,7 @@ void GPUCodegen::generate_resources() } ss << "};\n\n"; - info.uniform_buf(1, "NodeTree", GPU_UBO_BLOCK_NAME, Frequency::BATCH); + info.uniform_buf(GPU_NODE_TREE_UBO_SLOT, "NodeTree", GPU_UBO_BLOCK_NAME, Frequency::BATCH); } if (!BLI_listbase_is_empty(&graph.uniform_attrs.list)) {