75 GLuint program_id = 0;
77 GLuint vert_shader = 0;
78 GLuint geom_shader = 0;
79 GLuint frag_shader = 0;
80 GLuint compute_shader = 0;
83 GLProgram(GLProgram &&other)
85 program_id = other.program_id;
86 vert_shader = other.vert_shader;
87 geom_shader = other.geom_shader;
88 frag_shader = other.frag_shader;
89 compute_shader = other.compute_shader;
91 other.vert_shader = 0;
92 other.geom_shader = 0;
93 other.frag_shader = 0;
94 other.compute_shader = 0;
106 GLProgram *program_active_ =
nullptr;
110 bool async_compilation_ =
false;
117 GLSources vertex_sources_;
118 GLSources geometry_sources_;
119 GLSources fragment_sources_;
120 GLSources compute_sources_;
140 bool check_link_status();
146 GLuint program_get();
149 bool compilation_failed_ =
false;
153 std::string debug_source;
159 void init(
const shader::ShaderCreateInfo &info,
bool is_batch_compilation)
override;
166 bool finalize(
const shader::ShaderCreateInfo *info =
nullptr)
override;
167 bool post_finalize(
const shader::ShaderCreateInfo *info =
nullptr);
184 void bind()
override;
187 void uniform_float(
int location,
int comp_len,
int array_size,
const float *
data)
override;
188 void uniform_int(
int location,
int comp_len,
int array_size,
const int *
data)
override;
205 if (!vertex_sources_.is_empty()) {
208 if (!compute_sources_.is_empty()) {
211 return program_active_->compute_shader != 0;
217 const char *glsl_patch_get(GLenum gl_stage);
220 GLuint create_shader_stage(GLenum gl_stage,
232 MEM_CXX_CLASS_ALLOC_FUNCS(
"GLShader");
235#if BLI_SUBPROCESS_SUPPORT
237class GLCompilerWorker {
238 friend class GLShaderCompiler;
241 BlenderSubprocess subprocess_;
242 std::unique_ptr<SharedMemory> shared_mem_;
243 std::unique_ptr<SharedSemaphore> start_semaphore_;
244 std::unique_ptr<SharedSemaphore> end_semaphore_;
245 std::unique_ptr<SharedSemaphore> close_semaphore_;
248 COMPILATION_REQUESTED,
252 COMPILATION_FINISHED,
256 eState state_ = AVAILABLE;
257 double compilation_start = 0;
262 void compile(
const GLSourcesBaked &sources);
264 bool load_program_binary(GLint program);
274 Vector<GLCompilerWorker *> workers_;
276 struct CompilationWork {
277 const shader::ShaderCreateInfo *info =
nullptr;
278 GLShader *shader =
nullptr;
279 GLSourcesBaked sources;
281 GLCompilerWorker *worker =
nullptr;
282 bool do_async_compilation =
false;
283 bool is_ready =
false;
287 Vector<CompilationWork> items;
288 bool is_ready =
false;
291 Map<BatchHandle, Batch> batches;
293 struct SpecializationRequest {
295 Vector<ShaderSpecialization> specializations;
298 Vector<SpecializationRequest> specialization_queue;
300 struct SpecializationWork {
301 GLShader *shader =
nullptr;
302 Vector<shader::SpecializationConstant> constants;
303 GLSourcesBaked sources;
305 GLShader::GLProgram *program_get();
307 GLCompilerWorker *worker =
nullptr;
308 bool do_async_compilation =
false;
309 bool is_ready =
false;
312 struct SpecializationBatch {
314 Vector<SpecializationWork> items;
315 bool is_ready =
true;
318 SpecializationBatch current_specialization_batch;
319 void prepare_next_specialization_batch();
325 GLCompilerWorker *get_compiler_worker(
const GLSourcesBaked &sources);
326 bool worker_is_lost(GLCompilerWorker *&worker);
329 virtual ~GLShaderCompiler()
override;
336 Span<ShaderSpecialization> specializations)
override;
349 const char *
parse_line(
const char *source_combined,
350 const char *log_line,
int64_t SpecializationBatchHandle
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Map
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")
bool get_uses_ssbo_vertex_fetch() const override
std::string geometry_layout_declare(const shader::ShaderCreateInfo &info) const override
std::string vertex_interface_declare(const shader::ShaderCreateInfo &info) const override
std::string geometry_interface_declare(const shader::ShaderCreateInfo &info) const override
void fragment_shader_from_glsl(MutableSpan< const char * > sources) override
void uniform_float(int location, int comp_len, int array_size, const float *data) override
void transform_feedback_names_set(Span< const char * > name_list, eGPUShaderTFBType geom_type) override
bool post_finalize(const shader::ShaderCreateInfo *info=nullptr)
int get_ssbo_vertex_fetch_output_num_verts() const override
GLShader(const char *name)
GLSourcesBaked get_sources()
void compute_shader_from_glsl(MutableSpan< const char * > sources) override
std::string compute_layout_declare(const shader::ShaderCreateInfo &info) const override
std::string constants_declare() const
int program_handle_get() const override
std::string resources_declare(const shader::ShaderCreateInfo &info) const override
bool transform_feedback_enable(VertBuf *buf) override
friend class GLShaderCompiler
void uniform_int(int location, int comp_len, int array_size, const int *data) override
std::string fragment_interface_declare(const shader::ShaderCreateInfo &info) const override
bool finalize(const shader::ShaderCreateInfo *info=nullptr) override
void geometry_shader_from_glsl(MutableSpan< const char * > sources) override
void vertex_shader_from_glsl(MutableSpan< const char * > sources) override
void transform_feedback_disable() override
void warm_cache(int) override
Vector< const char * > sources_get() const
std::string to_string() const
GLSources & operator=(Span< const char * > other)
virtual bool batch_is_ready(BatchHandle handle) override
virtual BatchHandle batch_compile(Span< const shader::ShaderCreateInfo * > &infos) override
virtual Vector< Shader * > batch_finalize(BatchHandle &handle) override
virtual bool specialization_batch_is_ready(SpecializationBatchHandle &handle)
virtual SpecializationBatchHandle precompile_specializations(Span< ShaderSpecialization >)
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...