78 GLuint program_id = 0;
80 GLuint vert_shader = 0;
81 GLuint geom_shader = 0;
82 GLuint frag_shader = 0;
83 GLuint compute_shader = 0;
85 std::mutex compilation_mutex;
97 std::mutex program_cache_mutex_;
100 GLProgram *main_program_ =
nullptr;
104 bool is_codegen_only_ =
false;
127 bool compilation_failed_ =
false;
129 std::string debug_source;
140 return original_info;
167 void uniform_float(
int location,
int comp_len,
int array_size,
const float *
data)
override;
168 void uniform_int(
int location,
int comp_len,
int array_size,
const int *
data)
override;
172 if (!vertex_sources_.is_empty()) {
175 if (!compute_sources_.is_empty()) {
178 return main_program_->compute_shader != 0;
186 bool has_specialization_constants()
const
188 return constants->types.is_empty() ==
false;
192 GLuint create_shader_stage(GLenum gl_stage,
205 MEM_CXX_CLASS_ALLOC_FUNCS(
"GLShader");
217#if BLI_SUBPROCESS_SUPPORT
219class GLCompilerWorker {
223 BlenderSubprocess subprocess_;
224 std::unique_ptr<SharedMemory> shared_mem_;
225 std::unique_ptr<SharedSemaphore> start_semaphore_;
226 std::unique_ptr<SharedSemaphore> end_semaphore_;
227 std::unique_ptr<SharedSemaphore> close_semaphore_;
230 COMPILATION_REQUESTED,
234 COMPILATION_FINISHED,
238 std::atomic<State> state_ = AVAILABLE;
239 double compilation_start = 0;
244 void compile(
const GLSourcesBaked &sources);
245 bool block_until_ready();
246 bool load_program_binary(GLint program);
255 Vector<GLCompilerWorker *> workers_;
256 std::mutex workers_mutex_;
258 GLCompilerWorker *get_compiler_worker();
260 GLShader::GLProgram *specialization_program_get(ShaderSpecialization &specialization);
263 GLSubprocessShaderCompiler()
266 virtual ~GLSubprocessShaderCompiler()
override;
269 virtual void specialize_shader(
const ShaderSpecialization &specialization)
override;
280 const char *
parse_line(
const char *source_combined,
281 const char *log_line,
Read Blender memory allocation and freeing.
NonCopyable(const NonCopyable &other)=delete
const char * parse_line(const char *source_combined, const char *log_line, GPULogItem &log_item) override
const char * skip_severity_prefix(const char *log_line, GPULogItem &log_item)
const char * skip_severity_keyword(const char *log_line, GPULogItem &log_item)
MEM_CXX_CLASS_ALLOC_FUNCS("GLLogParser")
virtual void specialize_shader(const ShaderSpecialization &specialization) override
GLSourcesBaked get_sources()
std::string vertex_interface_declare(const shader::ShaderCreateInfo &info) const override
std::string resources_declare(const shader::ShaderCreateInfo &info) const override
std::string fragment_interface_declare(const shader::ShaderCreateInfo &info) const override
void vertex_shader_from_glsl(const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
void compute_shader_from_glsl(const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
std::string geometry_layout_declare(const shader::ShaderCreateInfo &info) const override
bool finalize(const shader::ShaderCreateInfo *info=nullptr) override
void uniform_float(int location, int comp_len, int array_size, const float *data) override
void fragment_shader_from_glsl(const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
void geometry_shader_from_glsl(const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
bool post_finalize(const shader::ShaderCreateInfo *info=nullptr)
GLShader(const char *name)
friend class GLShaderCompiler
friend class GLSubprocessShaderCompiler
void bind(const shader::SpecializationConstants *constants_state) override
void uniform_int(int location, int comp_len, int array_size, const int *data) override
std::string compute_layout_declare(const shader::ShaderCreateInfo &info) const override
void warm_cache(int) override
const shader::ShaderCreateInfo & patch_create_info(const shader::ShaderCreateInfo &original_info) override
std::string geometry_interface_declare(const shader::ShaderCreateInfo &info) const override
std::string constants_declare(const shader::SpecializationConstants &constants_state) const
Vector< StringRefNull > sources_get() const
std::string to_string() const
GLSources & operator=(Span< StringRefNull > other)
virtual void specialize_shader(const ShaderSpecialization &)
ShaderCompiler(uint32_t threads_count=1, GPUWorker::ContextType context_type=GPUWorker::ContextType::PerThread, bool support_specializations=false)
virtual Shader * compile_shader(const shader::ShaderCreateInfo &info)
std::unique_ptr< const shader::SpecializationConstants > constants
BMesh const char void * data
int GPU_max_parallel_compilations()
std::optional< StringRefNull > source_ref
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...