23 ShaderModule *ShaderModule::g_shader_module =
nullptr;
27 if (g_shader_module ==
nullptr) {
31 return g_shader_module;
36 if (g_shader_module !=
nullptr) {
38 delete g_shader_module;
39 g_shader_module =
nullptr;
52 const char *name = static_shader_create_info_name_get(
eShaderType(i));
53 if (name ==
nullptr) {
54 std::cerr <<
"EEVEE: Missing case for eShaderType(" << i
55 <<
") in static_shader_create_info_name_get().";
59 BLI_assert_msg(create_info !=
nullptr,
"EEVEE: Missing create info for static shader.");
78 const char *ShaderModule::static_shader_create_info_name_get(
eShaderType shader_type)
80 switch (shader_type) {
82 return "eevee_film_frag";
84 return "eevee_film_comp";
94 if (shaders_[shader_type] ==
nullptr) {
95 const char *shader_name = static_shader_create_info_name_get(shader_type);
99 if (shaders_[shader_type] ==
nullptr) {
100 fprintf(stderr,
"EEVEE: error: Could not compile static shader \"%s\"\n", shader_name);
104 return shaders_[shader_type];
130 info.
define(
"MAT_TRANSPARENT");
133 switch (geometry_type) {
136 info.
define(
"USE_BARYCENTRICS");
137 info.
builtins(BuiltinBits::BARYCENTRIC_COORD);
141 info.
define(
"USE_BARYCENTRICS");
149 std::stringstream global_vars;
150 switch (geometry_type) {
157 if (
input.name ==
"orco") {
159 global_vars <<
input.type <<
" " <<
input.name <<
";\n";
162 info.
sampler(0, ImageType::FLOAT_BUFFER,
input.name, Frequency::BATCH);
180 global_vars <<
input.type <<
" " <<
input.name <<
";\n";
190 const bool do_fragment_attrib_load = (geometry_type ==
MAT_GEOM_WORLD);
196 global_vars <<
"struct " << iface.
name <<
" {\n";
197 for (
const auto &inout : iface.
inouts) {
198 global_vars <<
" " << inout.type <<
" " << inout.name <<
";\n";
200 global_vars <<
"};\n";
206 std::stringstream attr_load;
207 attr_load <<
"void attrib_load()\n";
210 attr_load <<
"}\n\n";
212 std::stringstream vert_gen, frag_gen;
214 if (do_fragment_attrib_load) {
215 frag_gen << global_vars.str() << attr_load.str();
218 vert_gen << global_vars.str() << attr_load.str();
224 vert_gen <<
"vec3 nodetree_displacement()\n";
238 info.
define(
"MAT_DISPLACEMENT_BUMP");
240 frag_gen <<
"vec3 nodetree_displacement()\n";
246 frag_gen <<
"Closure nodetree_surface()\n";
248 frag_gen <<
" closure_weights_reset();\n";
249 frag_gen << ((codegen.
surface) ? codegen.
surface :
"return Closure(0);\n");
252 frag_gen <<
"Closure nodetree_volume()\n";
254 frag_gen <<
" closure_weights_reset();\n";
255 frag_gen << ((codegen.
volume) ? codegen.
volume :
"return Closure(0);\n");
258 frag_gen <<
"float nodetree_thickness()\n";
268 switch (geometry_type) {
288 switch (geometry_type) {
295 switch (pipeline_type) {
330 bool deferred_compilation)
337 blender_mat, nodetree, shader_uuid, is_volume, deferred_compilation,
codegen_callback,
this);
348 bool deferred_compilation =
false;
354 deferred_compilation,
#define BLI_assert_msg(a, msg)
#define DRW_SHADER_FREE_SAFE(shader)
GPUMaterial * GPU_material_from_nodetree(struct Scene *scene, struct Material *ma, struct bNodeTree *ntree, struct ListBase *gpumaterials, const char *name, uint64_t shader_uuid, bool is_volume_shader, bool is_lookdev, GPUCodegenCallbackFn callback, void *thunk)
uint64_t GPU_material_uuid_get(GPUMaterial *mat)
void GPU_material_compile(GPUMaterial *mat)
void GPU_material_status_set(GPUMaterial *mat, eGPUMaterialStatus status)
bool GPU_material_flag_get(const GPUMaterial *mat, eGPUMaterialFlag flag)
@ GPU_MATFLAG_BARYCENTRIC
@ GPU_MATFLAG_TRANSPARENT
struct GPUShader GPUShader
GPUShader * GPU_shader_create_from_info_name(const char *info_name)
struct GPUShaderCreateInfo GPUShaderCreateInfo
const GPUShaderCreateInfo * GPU_shader_create_info_get(const char *info_name)
GPUMaterial * material_shader_get(::Material *blender_mat, struct bNodeTree *nodetree, eMaterialPipeline pipeline_type, eMaterialGeometry geometry_type, bool deferred_compilation)
GPUMaterial * world_shader_get(::World *blender_world, struct bNodeTree *nodetree)
static void module_free()
static ShaderModule * module_get()
void material_create_info_ammend(GPUMaterial *mat, GPUCodegenOutput *codegen)
GPUShader * static_shader_get(eShaderType shader_type)
GPUMaterial * DRW_shader_from_world(World *wo, struct bNodeTree *ntree, const uint64_t shader_id, const bool is_volume_shader, bool deferred, GPUCodegenCallbackFn callback, void *thunk)
GPUMaterial * DRW_shader_from_material(Material *ma, struct bNodeTree *ntree, const uint64_t shader_id, const bool is_volume_shader, bool deferred, GPUCodegenCallbackFn callback, void *thunk)
smooth(Type::VEC4, "color_mul") .smooth(Type gpFillTexture gpSceneDepthTexture materials[GPENCIL_MATERIAL_BUFFER_LEN]
ccl_global KernelShaderEvalInput * input
static void material_type_from_shader_uuid(uint64_t shader_uuid, eMaterialPipeline &pipeline_type, eMaterialGeometry &geometry_type)
static uint64_t shader_uuid_from_material_type(eMaterialPipeline pipeline_type, eMaterialGeometry geometry_type)
@ MAT_PIPE_DEFERRED_PREPASS_VELOCITY
@ MAT_PIPE_FORWARD_PREPASS_VELOCITY
@ MAT_PIPE_DEFERRED_PREPASS
@ MAT_PIPE_FORWARD_PREPASS
static void codegen_callback(void *thunk, GPUMaterial *mat, GPUCodegenOutput *codegen)
unsigned __int64 uint64_t
char * material_functions
GPUShaderCreateInfo * create_info
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
Self & auto_resource_location(bool value)
Vector< StageInterfaceInfo * > vertex_out_interfaces_
Self & sampler(int slot, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS, eGPUSamplerState sampler=(eGPUSamplerState) -1)
std::string fragment_source_generated
Vector< VertIn > vertex_inputs_
Self & builtins(BuiltinBits builtin)
Self & additional_info(StringRefNull info_name0, StringRefNull info_name1="", StringRefNull info_name2="", StringRefNull info_name3="", StringRefNull info_name4="", StringRefNull info_name5="", StringRefNull info_name6="")
std::string vertex_source_generated
Self & define(StringRefNull name, StringRefNull value="")
StringRefNull instance_name