Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader.cc')
-rw-r--r--source/blender/gpu/intern/gpu_shader.cc44
1 files changed, 21 insertions, 23 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index b434cfbbb0e..fe9aacb95f9 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -249,6 +249,19 @@ const GPUShaderCreateInfo *GPU_shader_create_info_get(const char *info_name)
return gpu_shader_create_info_get(info_name);
}
+bool GPU_shader_create_info_check_error(const GPUShaderCreateInfo *_info, char r_error[128])
+{
+ using namespace blender::gpu::shader;
+ const ShaderCreateInfo &info = *reinterpret_cast<const ShaderCreateInfo *>(_info);
+ std::string error = info.check_error();
+ if (error.length() == 0) {
+ return true;
+ }
+
+ BLI_strncpy(r_error, error.c_str(), 128);
+ return false;
+}
+
GPUShader *GPU_shader_create_from_info_name(const char *info_name)
{
using namespace blender::gpu::shader;
@@ -270,28 +283,10 @@ GPUShader *GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
GPU_debug_group_begin(GPU_DEBUG_SHADER_COMPILATION_GROUP);
- /* At least a vertex shader and a fragment shader are required, or only a compute shader. */
- if (info.compute_source_.is_empty()) {
- if (info.vertex_source_.is_empty()) {
- printf("Missing vertex shader in %s.\n", info.name_.c_str());
- }
- if (info.fragment_source_.is_empty()) {
- printf("Missing fragment shader in %s.\n", info.name_.c_str());
- }
- BLI_assert(!info.vertex_source_.is_empty() && !info.fragment_source_.is_empty());
- }
- else {
- if (!info.vertex_source_.is_empty()) {
- printf("Compute shader has vertex_source_ shader attached in %s.\n", info.name_.c_str());
- }
- if (!info.geometry_source_.is_empty()) {
- printf("Compute shader has geometry_source_ shader attached in %s.\n", info.name_.c_str());
- }
- if (!info.fragment_source_.is_empty()) {
- printf("Compute shader has fragment_source_ shader attached in %s.\n", info.name_.c_str());
- }
- BLI_assert(info.vertex_source_.is_empty() && info.geometry_source_.is_empty() &&
- info.fragment_source_.is_empty());
+ const std::string error = info.check_error();
+ if (!error.empty()) {
+ printf("%s\n", error.c_str());
+ BLI_assert(false);
}
Shader *shader = GPUBackend::get()->shader_alloc(info.name_.c_str());
@@ -299,7 +294,9 @@ GPUShader *GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
std::string defines = shader->defines_declare(info);
std::string resources = shader->resources_declare(info);
- defines += "#define USE_GPU_SHADER_CREATE_INFO\n";
+ if (info.legacy_resource_location_ == false) {
+ defines += "#define USE_GPU_SHADER_CREATE_INFO\n";
+ }
Vector<const char *> typedefs;
if (!info.typedef_sources_.is_empty() || !info.typedef_source_generated.empty()) {
@@ -367,6 +364,7 @@ GPUShader *GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
sources.append(resources.c_str());
sources.append(layout.c_str());
sources.append(interface.c_str());
+ sources.append(info.geometry_source_generated.c_str());
sources.extend(code);
shader->geometry_shader_from_glsl(sources);