diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-05-09 14:40:10 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-05-09 14:40:10 +0300 |
commit | 95ff5e6d894e81a2f57b29e1cd7fb0fe4141a41f (patch) | |
tree | 545eda051408b282d1d4941add442a040c6b2419 /source/blender | |
parent | 719c86c0a65d0e9301fa879b23e3a78229d6f1c8 (diff) | |
parent | 0f7da9a72fa2dd610195e5009205b1b91c5ca132 (diff) |
Merge branch 'blender-v3.2-release'
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.cc | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index b6b0825a993..fa911037d00 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -32,6 +32,7 @@ #include "GPU_vertex_format.h" #include "BLI_sys_types.h" /* for intptr_t support */ +#include "BLI_vector.hh" #include "gpu_codegen.h" #include "gpu_material_library.h" @@ -58,6 +59,14 @@ struct GPUCodegenCreateInfo : ShaderCreateInfo { /** Duplicate attribute names to avoid reference the GPUNodeGraph directly. */ char attr_names[16][GPU_MAX_SAFE_ATTR_NAME + 1]; char var_names[16][8]; + blender::Vector<std::array<char, 32>, 16> sampler_names; + + void append_sampler_name(const char name[32]) + { + std::array<char, 32> sampler_name; + memcpy(sampler_name.data(), name, 32); + sampler_names.append(sampler_name); + } }; /** Optional generated interface. */ @@ -348,14 +357,28 @@ void GPUCodegen::generate_resources() /* Textures. */ LISTBASE_FOREACH (GPUMaterialTexture *, tex, &graph.textures) { if (tex->colorband) { - info.sampler(0, ImageType::FLOAT_1D_ARRAY, tex->sampler_name, Frequency::BATCH); + info.name_buffer->append_sampler_name(tex->sampler_name); + info.sampler(0, + ImageType::FLOAT_1D_ARRAY, + info.name_buffer->sampler_names.last().data(), + Frequency::BATCH); } else if (tex->tiled_mapping_name[0] != '\0') { - info.sampler(0, ImageType::FLOAT_2D_ARRAY, tex->sampler_name, Frequency::BATCH); - info.sampler(0, ImageType::FLOAT_1D_ARRAY, tex->tiled_mapping_name, Frequency::BATCH); + info.name_buffer->append_sampler_name(tex->sampler_name); + info.sampler(0, + ImageType::FLOAT_2D_ARRAY, + info.name_buffer->sampler_names.last().data(), + Frequency::BATCH); + info.name_buffer->append_sampler_name(tex->tiled_mapping_name); + info.sampler(0, + ImageType::FLOAT_1D_ARRAY, + info.name_buffer->sampler_names.last().data(), + Frequency::BATCH); } else { - info.sampler(0, ImageType::FLOAT_2D, tex->sampler_name, Frequency::BATCH); + info.name_buffer->append_sampler_name(tex->sampler_name); + info.sampler( + 0, ImageType::FLOAT_2D, info.name_buffer->sampler_names.last().data(), Frequency::BATCH); } } |