29#define DEBUG_LOG_SHADER_SRC_ON_ERROR 0
36#define SOURCES_INDEX_VERSION 0
37#define SOURCES_INDEX_SPECIALIZATION_CONSTANTS 1
52 std::unique_ptr<const shader::SpecializationConstants>
constants;
89 virtual void uniform_float(
int location,
int comp_len,
int array_size,
const float *
data) = 0;
90 virtual void uniform_int(
int location,
int comp_len,
int array_size,
const int *
data) = 0;
144 std::atomic<int> pending_compilations = 0;
146 bool is_specialization_batch()
154 return pending_compilations == 0;
169 std::condition_variable compilation_finished_notification_;
171 struct ParallelWork {
172 Batch *
batch =
nullptr;
173 int shader_index = 0;
176 struct CompilationQueue {
177 std::deque<ParallelWork> low_priority;
178 std::deque<ParallelWork> normal_priority;
179 std::deque<ParallelWork> high_priority;
185 low_priority.push_back(work);
188 normal_priority.push_back(work);
191 high_priority.push_back(work);
201 if (!high_priority.empty()) {
202 ParallelWork work = high_priority.front();
203 high_priority.pop_front();
206 if (!normal_priority.empty()) {
207 ParallelWork work = normal_priority.front();
208 normal_priority.pop_front();
211 if (!low_priority.empty()) {
212 ParallelWork work = low_priority.front();
213 low_priority.pop_front();
222 return low_priority.empty() && normal_priority.empty() && high_priority.empty();
225 void remove_batch(Batch *
batch)
227 auto remove = [](std::deque<ParallelWork> &queue, Batch *
batch) {
228 for (ParallelWork &work : queue) {
229 if (work.batch ==
batch) {
231 batch->pending_compilations--;
235 queue.erase(std::remove_if(queue.begin(),
237 [](
const ParallelWork &work) { return !work.batch; }),
241 remove(low_priority,
batch);
242 remove(normal_priority,
batch);
243 remove(high_priority,
batch);
246 CompilationQueue compilation_queue_;
248 std::unique_ptr<GPUWorker> compilation_worker_;
250 bool support_specializations_;
253 void do_work(
void *work_payload);
257 bool is_compiling_impl();
264 compilation_worker_.reset();
270 bool support_specializations =
false);
315 const char *log_line,
321 const char *error_msg,
322 const char *warning_msg,
323 const char *note_msg)
const;
325 const char *
skip_until(
const char *log_line,
char stop_char)
const;
326 bool at_number(
const char *log_line)
const;
328 int parse_number(
const char *log_line,
const char **r_new_position)
const;
#define BLI_assert_unreachable()
void GPU_shader_free(blender::gpu::Shader *shader)
int64_t SpecializationBatchHandle
BMesh const char void * data
static size_t line_start_get(StringRefNull source_combined, size_t target_line)
static StringRef filename_get(StringRefNull source_combined, size_t pos)
int parse_number(const char *log_line, const char **r_new_position) const
const char * skip_separators(const char *log_line, const StringRef separators) const
bool at_number(const char *log_line) const
static size_t source_line_get(StringRefNull source_combined, size_t pos)
bool at_any(const char *log_line, const StringRef chars) const
virtual const char * parse_line(const char *source_combined, const char *log_line, GPULogItem &log_item)=0
const char * skip_until(const char *log_line, char stop_char) const
MEM_CXX_CLASS_ALLOC_FUNCS("GPULogParser")
const char * skip_severity(const char *log_line, GPULogItem &log_item, const char *error_msg, const char *warning_msg, const char *note_msg) const
void batch_cancel(BatchHandle &handle)
BatchHandle batch_compile(Span< const shader::ShaderCreateInfo * > &infos, CompilationPriority priority)
bool specialization_batch_is_ready(SpecializationBatchHandle &handle)
Vector< Shader * > batch_finalize(BatchHandle &handle)
Shader * compile(const shader::ShaderCreateInfo &info, bool is_batch_compilation)
virtual void specialize_shader(ShaderSpecialization &)
bool batch_is_ready(BatchHandle handle)
ShaderCompiler(uint32_t threads_count=1, GPUWorker::ContextType context_type=GPUWorker::ContextType::PerThread, bool support_specializations=false)
void destruct_compilation_worker()
virtual ~ShaderCompiler()
SpecializationBatchHandle precompile_specializations(Span< ShaderSpecialization > specializations, CompilationPriority priority)
virtual Shader * compile_shader(const shader::ShaderCreateInfo &info)
uint16_t fragment_output_bits
virtual std::string fragment_interface_declare(const shader::ShaderCreateInfo &info) const =0
virtual void uniform_int(int location, int comp_len, int array_size, const int *data)=0
std::string defines_declare(const shader::ShaderCreateInfo &info) const
virtual void compute_shader_from_glsl(MutableSpan< StringRefNull > sources)=0
virtual void init(const shader::ShaderCreateInfo &info, bool is_batch_compilation)=0
virtual void bind(const shader::SpecializationConstants *constants_state)=0
std::unique_ptr< const shader::SpecializationConstants > constants
virtual void vertex_shader_from_glsl(MutableSpan< StringRefNull > sources)=0
virtual std::string compute_layout_declare(const shader::ShaderCreateInfo &info) const =0
Shader * parent_get() const
virtual void fragment_shader_from_glsl(MutableSpan< StringRefNull > sources)=0
virtual bool finalize(const shader::ShaderCreateInfo *info=nullptr)=0
StringRefNull name_get() const
virtual std::string resources_declare(const shader::ShaderCreateInfo &info) const =0
virtual std::string geometry_interface_declare(const shader::ShaderCreateInfo &info) const =0
void specialization_constants_init(const shader::ShaderCreateInfo &info)
virtual void geometry_shader_from_glsl(MutableSpan< StringRefNull > sources)=0
virtual void warm_cache(int limit)=0
void parent_set(Shader *parent)
virtual std::string vertex_interface_declare(const shader::ShaderCreateInfo &info) const =0
static void set_scene_linear_to_xyz_uniform(gpu::Shader *shader)
virtual void uniform_float(int location, int comp_len, int array_size, const float *data)=0
void print_log(Span< StringRefNull > sources, const char *log, const char *stage, bool error, GPULogParser *parser)
static void set_framebuffer_srgb_target(int use_srgb_to_linear)
virtual std::string geometry_layout_declare(const shader::ShaderCreateInfo &info) const =0
static void set_srgb_uniform(Context *ctx, gpu::Shader *shader)
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
blender::gpu::Shader * immGetShader()
static void error(const char *str)
void printf_begin(Context *ctx)
void printf_end(Context *ctx)
std::string file_name_and_error_line
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...