diff --git a/source/blender/gpu/GPU_shader.hh b/source/blender/gpu/GPU_shader.hh index 676f3ab1180..627bb6dd53f 100644 --- a/source/blender/gpu/GPU_shader.hh +++ b/source/blender/gpu/GPU_shader.hh @@ -309,30 +309,6 @@ void GPU_shader_batch_specializations_cancel(SpecializationBatchHandle &handle); * All of this section is deprecated and should be ported to use the API described above. * \{ */ -blender::gpu::Shader *GPU_shader_create(std::optional vertcode, - std::optional fragcode, - std::optional geomcode, - std::optional libcode, - std::optional defines, - blender::StringRefNull shname); -blender::gpu::Shader *GPU_shader_create_compute(std::optional computecode, - std::optional libcode, - std::optional defines, - blender::StringRefNull shname); -blender::gpu::Shader *GPU_shader_create_from_python(std::optional vertcode, - std::optional fragcode, - std::optional geomcode, - std::optional libcode, - std::optional defines, - std::optional name); -blender::gpu::Shader *GPU_shader_create_ex(std::optional vertcode, - std::optional fragcode, - std::optional geomcode, - std::optional computecode, - std::optional libcode, - std::optional defines, - blender::StringRefNull shname); - /** * Shader cache warming. * For each shader, rendering APIs perform a two-step compilation: @@ -432,9 +408,6 @@ enum GPUUniformBlockBuiltin { GPU_NUM_UNIFORM_BLOCKS, /* Special value, denotes number of builtin uniforms block. */ }; -/** DEPRECATED: Use hard-coded buffer location instead. */ -int GPU_shader_get_builtin_block(blender::gpu::Shader *shader, int builtin); - /** DEPRECATED: Kept only because of Python GPU API. */ int GPU_shader_get_uniform_block(blender::gpu::Shader *shader, const char *name); diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc index 1e28983cc87..02626b33d07 100644 --- a/source/blender/gpu/intern/gpu_shader.cc +++ b/source/blender/gpu/intern/gpu_shader.cc @@ -119,95 +119,6 @@ static void standard_defines(Vector &sources) } } -blender::gpu::Shader *GPU_shader_create_ex(const std::optional vertcode, - const std::optional fragcode, - const std::optional geomcode, - const std::optional computecode, - const std::optional libcode, - const std::optional defines, - const StringRefNull shname) -{ - /* At least a vertex shader and a fragment shader are required, or only a compute shader. */ - BLI_assert((fragcode.has_value() && vertcode.has_value() && !computecode.has_value()) || - (!fragcode.has_value() && !vertcode.has_value() && !geomcode.has_value() && - computecode.has_value())); - - Shader *shader = GPUBackend::get()->shader_alloc(shname.c_str()); - /* Needs to be called before init as GL uses the default specialization constants state to insert - * default shader inside a map. */ - shader->constants = std::make_unique(); - shader->init(); - - if (vertcode) { - Vector sources; - standard_defines(sources); - sources.append("#define GPU_VERTEX_SHADER\n"); - sources.append("#define IN_OUT out\n"); - if (geomcode) { - sources.append("#define USE_GEOMETRY_SHADER\n"); - } - if (defines) { - sources.append(*defines); - } - sources.append(*vertcode); - - shader->vertex_shader_from_glsl(sources); - } - - if (fragcode) { - Vector sources; - standard_defines(sources); - sources.append("#define GPU_FRAGMENT_SHADER\n"); - sources.append("#define IN_OUT in\n"); - if (geomcode) { - sources.append("#define USE_GEOMETRY_SHADER\n"); - } - if (defines) { - sources.append(*defines); - } - if (libcode) { - sources.append(*libcode); - } - sources.append(*fragcode); - - shader->fragment_shader_from_glsl(sources); - } - - if (geomcode) { - Vector sources; - standard_defines(sources); - sources.append("#define GPU_GEOMETRY_SHADER\n"); - if (defines) { - sources.append(*defines); - } - sources.append(*geomcode); - - shader->geometry_shader_from_glsl(sources); - } - - if (computecode) { - Vector sources; - standard_defines(sources); - sources.append("#define GPU_COMPUTE_SHADER\n"); - if (defines) { - sources.append(*defines); - } - if (libcode) { - sources.append(*libcode); - } - sources.append(*computecode); - - shader->compute_shader_from_glsl(sources); - } - - if (!shader->finalize()) { - delete shader; - return nullptr; - }; - - return shader; -} - void GPU_shader_free(blender::gpu::Shader *shader) { delete shader; @@ -219,26 +130,6 @@ void GPU_shader_free(blender::gpu::Shader *shader) /** \name Creation utils * \{ */ -blender::gpu::Shader *GPU_shader_create(const std::optional vertcode, - const std::optional fragcode, - const std::optional geomcode, - const std::optional libcode, - const std::optional defines, - const StringRefNull shname) -{ - return GPU_shader_create_ex( - vertcode, fragcode, geomcode, std::nullopt, libcode, defines, shname); -} - -blender::gpu::Shader *GPU_shader_create_compute(const std::optional computecode, - const std::optional libcode, - const std::optional defines, - const StringRefNull shname) -{ - return GPU_shader_create_ex( - std::nullopt, std::nullopt, std::nullopt, computecode, libcode, defines, shname); -} - const GPUShaderCreateInfo *GPU_shader_create_info_get(const char *info_name) { return gpu_shader_create_info_get(info_name); @@ -311,63 +202,6 @@ blender::gpu::Shader *GPU_shader_create_from_info_python(const GPUShaderCreateIn return result; } -blender::gpu::Shader *GPU_shader_create_from_python(std::optional vertcode, - std::optional fragcode, - std::optional geomcode, - std::optional libcode, - std::optional defines, - const std::optional name) -{ - std::string defines_cat = "#define GPU_RAW_PYTHON_SHADER\n"; - if (defines) { - defines_cat += defines.value(); - defines = defines_cat; - } - else { - defines = defines_cat; - } - - std::string libcodecat; - - if (!libcode) { - libcode = datatoc_gpu_shader_colorspace_lib_glsl; - } - else { - libcodecat = *libcode + datatoc_gpu_shader_colorspace_lib_glsl; - libcode = libcodecat; - } - - std::string vertex_source_processed; - std::string fragment_source_processed; - std::string geometry_source_processed; - std::string library_source_processed; - - if (vertcode.has_value()) { - vertex_source_processed = GPU_shader_preprocess_source(*vertcode); - vertcode = vertex_source_processed; - } - if (fragcode.has_value()) { - fragment_source_processed = GPU_shader_preprocess_source(*fragcode); - fragcode = fragment_source_processed; - } - if (geomcode.has_value()) { - geometry_source_processed = GPU_shader_preprocess_source(*geomcode); - geomcode = geometry_source_processed; - } - if (libcode.has_value()) { - library_source_processed = GPU_shader_preprocess_source(*libcode); - libcode = library_source_processed; - } - - /* Use pyGPUShader as default name for shader. */ - blender::StringRefNull shname = name.value_or("pyGPUShader"); - - blender::gpu::Shader *sh = GPU_shader_create_ex( - vertcode, fragcode, geomcode, std::nullopt, libcode, defines, shname); - - return sh; -} - BatchHandle GPU_shader_batch_create_from_infos(Span infos, CompilationPriority priority) { @@ -575,12 +409,6 @@ int GPU_shader_get_builtin_uniform(blender::gpu::Shader *shader, int builtin) return interface->uniform_builtin((GPUUniformBuiltin)builtin); } -int GPU_shader_get_builtin_block(blender::gpu::Shader *shader, int builtin) -{ - const ShaderInterface *interface = shader->interface; - return interface->ubo_builtin((GPUUniformBlockBuiltin)builtin); -} - int GPU_shader_get_ssbo_binding(blender::gpu::Shader *shader, const char *name) { const ShaderInterface *interface = shader->interface; diff --git a/source/blender/gpu/intern/gpu_shader_private.hh b/source/blender/gpu/intern/gpu_shader_private.hh index 3f487434838..072efd3f204 100644 --- a/source/blender/gpu/intern/gpu_shader_private.hh +++ b/source/blender/gpu/intern/gpu_shader_private.hh @@ -71,8 +71,6 @@ class Shader { /* TODO: Remove `is_batch_compilation`. */ virtual void init(const shader::ShaderCreateInfo &info, bool is_batch_compilation) = 0; - /* Variant for legacy python shaders. To be removed, not supported in Vulkan or Metal. */ - virtual void init() = 0; virtual void vertex_shader_from_glsl(MutableSpan sources) = 0; virtual void geometry_shader_from_glsl(MutableSpan sources) = 0; diff --git a/source/blender/gpu/metal/mtl_shader.hh b/source/blender/gpu/metal/mtl_shader.hh index 5f1d3b27830..ecc7488779a 100644 --- a/source/blender/gpu/metal/mtl_shader.hh +++ b/source/blender/gpu/metal/mtl_shader.hh @@ -234,7 +234,6 @@ class MTLShader : public Shader { ~MTLShader(); void init(const shader::ShaderCreateInfo & /*info*/, bool is_batch_compilation) override; - void init() override {} /* Assign GLSL source. */ void vertex_shader_from_glsl(MutableSpan sources) override; diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index a5b1cb266f6..5ee87a0ce1f 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -87,18 +87,6 @@ void GLShader::init(const shader::ShaderCreateInfo &info, bool is_batch_compilat } } -void GLShader::init() -{ - main_program_ = program_cache_ - .lookup_or_add_cb(constants->values, - []() { return std::make_unique(); }) - .get(); - if (!main_program_->program_id) { - main_program_->program_id = glCreateProgram(); - debug::object_label(GL_PROGRAM, main_program_->program_id, name); - } -} - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/gpu/opengl/gl_shader.hh b/source/blender/gpu/opengl/gl_shader.hh index 1c6de5daa66..d5b365b2d4e 100644 --- a/source/blender/gpu/opengl/gl_shader.hh +++ b/source/blender/gpu/opengl/gl_shader.hh @@ -133,7 +133,6 @@ class GLShader : public Shader { ~GLShader(); void init(const shader::ShaderCreateInfo &info, bool is_batch_compilation) override; - void init() override; /** Return true on success. */ void vertex_shader_from_glsl(MutableSpan sources) override; diff --git a/source/blender/gpu/vulkan/vk_shader.hh b/source/blender/gpu/vulkan/vk_shader.hh index 63ca737da5b..ff12f5b21b8 100644 --- a/source/blender/gpu/vulkan/vk_shader.hh +++ b/source/blender/gpu/vulkan/vk_shader.hh @@ -58,7 +58,6 @@ class VKShader : public Shader { virtual ~VKShader(); void init(const shader::ShaderCreateInfo &info, bool is_batch_compilation) override; - void init() override {} void vertex_shader_from_glsl(MutableSpan sources) override; void geometry_shader_from_glsl(MutableSpan sources) override;