GPUShader: Add name for debugging & identifying shaders.
This commit is contained in:
@@ -257,7 +257,7 @@ void DRW_deferred_shader_remove(GPUMaterial *mat)
|
|||||||
|
|
||||||
GPUShader *DRW_shader_create(const char *vert, const char *geom, const char *frag, const char *defines)
|
GPUShader *DRW_shader_create(const char *vert, const char *geom, const char *frag, const char *defines)
|
||||||
{
|
{
|
||||||
return GPU_shader_create(vert, frag, geom, NULL, defines);
|
return GPU_shader_create(vert, frag, geom, NULL, defines, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUShader *DRW_shader_create_with_lib(
|
GPUShader *DRW_shader_create_with_lib(
|
||||||
@@ -274,7 +274,7 @@ GPUShader *DRW_shader_create_with_lib(
|
|||||||
geom_with_lib = BLI_string_joinN(lib, geom);
|
geom_with_lib = BLI_string_joinN(lib, geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, NULL, defines);
|
sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, NULL, defines, __func__);
|
||||||
|
|
||||||
MEM_freeN(vert_with_lib);
|
MEM_freeN(vert_with_lib);
|
||||||
MEM_freeN(frag_with_lib);
|
MEM_freeN(frag_with_lib);
|
||||||
@@ -290,22 +290,22 @@ GPUShader *DRW_shader_create_with_transform_feedback(
|
|||||||
const GPUShaderTFBType prim_type, const char **varying_names, const int varying_count)
|
const GPUShaderTFBType prim_type, const char **varying_names, const int varying_count)
|
||||||
{
|
{
|
||||||
return GPU_shader_create_ex(vert, NULL, geom, NULL, defines, GPU_SHADER_FLAGS_NONE,
|
return GPU_shader_create_ex(vert, NULL, geom, NULL, defines, GPU_SHADER_FLAGS_NONE,
|
||||||
prim_type, varying_names, varying_count);
|
prim_type, varying_names, varying_count, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUShader *DRW_shader_create_2D(const char *frag, const char *defines)
|
GPUShader *DRW_shader_create_2D(const char *frag, const char *defines)
|
||||||
{
|
{
|
||||||
return GPU_shader_create(datatoc_gpu_shader_2D_vert_glsl, frag, NULL, NULL, defines);
|
return GPU_shader_create(datatoc_gpu_shader_2D_vert_glsl, frag, NULL, NULL, defines, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUShader *DRW_shader_create_3D(const char *frag, const char *defines)
|
GPUShader *DRW_shader_create_3D(const char *frag, const char *defines)
|
||||||
{
|
{
|
||||||
return GPU_shader_create(datatoc_gpu_shader_3D_vert_glsl, frag, NULL, NULL, defines);
|
return GPU_shader_create(datatoc_gpu_shader_3D_vert_glsl, frag, NULL, NULL, defines, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines)
|
GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines)
|
||||||
{
|
{
|
||||||
return GPU_shader_create(datatoc_common_fullscreen_vert_glsl, frag, NULL, NULL, defines);
|
return GPU_shader_create(datatoc_common_fullscreen_vert_glsl, frag, NULL, NULL, defines, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUShader *DRW_shader_create_3D_depth_only(void)
|
GPUShader *DRW_shader_create_3D_depth_only(void)
|
||||||
@@ -351,7 +351,7 @@ GPUMaterial *DRW_shader_create_from_world(
|
|||||||
if (mat == NULL) {
|
if (mat == NULL) {
|
||||||
mat = GPU_material_from_nodetree(
|
mat = GPU_material_from_nodetree(
|
||||||
scene, wo->nodetree, &wo->gpumaterial, engine_type, options,
|
scene, wo->nodetree, &wo->gpumaterial, engine_type, options,
|
||||||
vert, geom, frag_lib, defines);
|
vert, geom, frag_lib, defines, wo->id.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
|
if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
|
||||||
@@ -373,7 +373,7 @@ GPUMaterial *DRW_shader_create_from_material(
|
|||||||
if (mat == NULL) {
|
if (mat == NULL) {
|
||||||
mat = GPU_material_from_nodetree(
|
mat = GPU_material_from_nodetree(
|
||||||
scene, ma->nodetree, &ma->gpumaterial, engine_type, options,
|
scene, ma->nodetree, &ma->gpumaterial, engine_type, options,
|
||||||
vert, geom, frag_lib, defines);
|
vert, geom, frag_lib, defines, ma->id.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
|
if (GPU_material_status(mat) == GPU_MAT_QUEUED) {
|
||||||
|
@@ -247,7 +247,7 @@ GPUMaterial *GPU_material_from_nodetree_find(
|
|||||||
struct ListBase *gpumaterials, const void *engine_type, int options);
|
struct ListBase *gpumaterials, const void *engine_type, int options);
|
||||||
GPUMaterial *GPU_material_from_nodetree(
|
GPUMaterial *GPU_material_from_nodetree(
|
||||||
struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, const void *engine_type, int options,
|
struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, const void *engine_type, int options,
|
||||||
const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines);
|
const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines, const char *name);
|
||||||
void GPU_material_compile(GPUMaterial *mat);
|
void GPU_material_compile(GPUMaterial *mat);
|
||||||
void GPU_material_free(struct ListBase *gpumaterial);
|
void GPU_material_free(struct ListBase *gpumaterial);
|
||||||
|
|
||||||
|
@@ -62,7 +62,8 @@ GPUShader *GPU_shader_create(
|
|||||||
const char *fragcode,
|
const char *fragcode,
|
||||||
const char *geocode,
|
const char *geocode,
|
||||||
const char *libcode,
|
const char *libcode,
|
||||||
const char *defines);
|
const char *defines,
|
||||||
|
const char *shader_name);
|
||||||
GPUShader *GPU_shader_create_ex(
|
GPUShader *GPU_shader_create_ex(
|
||||||
const char *vertexcode,
|
const char *vertexcode,
|
||||||
const char *fragcode,
|
const char *fragcode,
|
||||||
@@ -72,7 +73,8 @@ GPUShader *GPU_shader_create_ex(
|
|||||||
const int flags,
|
const int flags,
|
||||||
const GPUShaderTFBType tf_type,
|
const GPUShaderTFBType tf_type,
|
||||||
const char **tf_names,
|
const char **tf_names,
|
||||||
const int tf_count);
|
const int tf_count,
|
||||||
|
const char *shader_name);
|
||||||
void GPU_shader_free(GPUShader *shader);
|
void GPU_shader_free(GPUShader *shader);
|
||||||
|
|
||||||
void GPU_shader_bind(GPUShader *shader);
|
void GPU_shader_bind(GPUShader *shader);
|
||||||
|
@@ -243,7 +243,8 @@ static GPUShader *gpu_basic_shader(int options)
|
|||||||
datatoc_gpu_shader_basic_frag_glsl,
|
datatoc_gpu_shader_basic_frag_glsl,
|
||||||
geom_glsl,
|
geom_glsl,
|
||||||
NULL,
|
NULL,
|
||||||
defines);
|
defines,
|
||||||
|
__func__);
|
||||||
|
|
||||||
if (shader) {
|
if (shader) {
|
||||||
/* set texture map to first texture unit */
|
/* set texture map to first texture unit */
|
||||||
|
@@ -1993,7 +1993,7 @@ GPUPass *GPU_generate_pass_new(
|
|||||||
return pass;
|
return pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_pass_compile(GPUPass *pass)
|
void GPU_pass_compile(GPUPass *pass, const char *shname)
|
||||||
{
|
{
|
||||||
if (!pass->compiled) {
|
if (!pass->compiled) {
|
||||||
pass->shader = GPU_shader_create(
|
pass->shader = GPU_shader_create(
|
||||||
@@ -2001,7 +2001,8 @@ void GPU_pass_compile(GPUPass *pass)
|
|||||||
pass->fragmentcode,
|
pass->fragmentcode,
|
||||||
pass->geometrycode,
|
pass->geometrycode,
|
||||||
NULL,
|
NULL,
|
||||||
pass->defines);
|
pass->defines,
|
||||||
|
shname);
|
||||||
pass->compiled = true;
|
pass->compiled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -184,7 +184,7 @@ void GPU_nodes_extract_dynamic_inputs(struct GPUShader *shader, ListBase *inputs
|
|||||||
void GPU_nodes_get_vertex_attributes(ListBase *nodes, struct GPUVertexAttribs *attribs);
|
void GPU_nodes_get_vertex_attributes(ListBase *nodes, struct GPUVertexAttribs *attribs);
|
||||||
void GPU_nodes_prune(ListBase *nodes, struct GPUNodeLink *outlink);
|
void GPU_nodes_prune(ListBase *nodes, struct GPUNodeLink *outlink);
|
||||||
|
|
||||||
void GPU_pass_compile(GPUPass *pass);
|
void GPU_pass_compile(GPUPass *pass, const char *shname);
|
||||||
void GPU_pass_release(GPUPass *pass);
|
void GPU_pass_release(GPUPass *pass);
|
||||||
void GPU_pass_free_nodes(ListBase *nodes);
|
void GPU_pass_free_nodes(ListBase *nodes);
|
||||||
|
|
||||||
|
@@ -43,6 +43,7 @@
|
|||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_listbase.h"
|
#include "BLI_listbase.h"
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
|
#include "BLI_string.h"
|
||||||
|
|
||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
@@ -120,6 +121,10 @@ struct GPUMaterial {
|
|||||||
short int sss_falloff;
|
short int sss_falloff;
|
||||||
float sss_sharpness;
|
float sss_sharpness;
|
||||||
bool sss_dirty;
|
bool sss_dirty;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
char name[64];
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -581,7 +586,7 @@ GPUMaterial *GPU_material_from_nodetree_find(
|
|||||||
*/
|
*/
|
||||||
GPUMaterial *GPU_material_from_nodetree(
|
GPUMaterial *GPU_material_from_nodetree(
|
||||||
Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options,
|
Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options,
|
||||||
const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines)
|
const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines, const char *name)
|
||||||
{
|
{
|
||||||
LinkData *link;
|
LinkData *link;
|
||||||
bool has_volume_output, has_surface_output;
|
bool has_volume_output, has_surface_output;
|
||||||
@@ -594,6 +599,11 @@ GPUMaterial *GPU_material_from_nodetree(
|
|||||||
mat->scene = scene;
|
mat->scene = scene;
|
||||||
mat->engine_type = engine_type;
|
mat->engine_type = engine_type;
|
||||||
mat->options = options;
|
mat->options = options;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
BLI_snprintf(mat->name, sizeof(mat->name), "%s", name);
|
||||||
|
#else
|
||||||
|
UNUSED_VARS(name);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* localize tree to create links for reroute and mute */
|
/* localize tree to create links for reroute and mute */
|
||||||
bNodeTree *localtree = ntreeLocalize(ntree);
|
bNodeTree *localtree = ntreeLocalize(ntree);
|
||||||
@@ -666,7 +676,12 @@ void GPU_material_compile(GPUMaterial *mat)
|
|||||||
|
|
||||||
/* NOTE: The shader may have already been compiled here since we are
|
/* NOTE: The shader may have already been compiled here since we are
|
||||||
* sharing GPUShader across GPUMaterials. In this case it's a no-op. */
|
* sharing GPUShader across GPUMaterials. In this case it's a no-op. */
|
||||||
GPU_pass_compile(mat->pass);
|
#ifndef NDEBUG
|
||||||
|
GPU_pass_compile(mat->pass, mat->name);
|
||||||
|
#else
|
||||||
|
GPU_pass_compile(mat->pass, __func__);
|
||||||
|
#endif
|
||||||
|
|
||||||
GPUShader *sh = GPU_pass_shader_get(mat->pass);
|
GPUShader *sh = GPU_pass_shader_get(mat->pass);
|
||||||
|
|
||||||
if (sh != NULL) {
|
if (sh != NULL) {
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "BLI_math_base.h"
|
#include "BLI_math_base.h"
|
||||||
#include "BLI_math_vector.h"
|
#include "BLI_math_vector.h"
|
||||||
#include "BLI_path_util.h"
|
#include "BLI_path_util.h"
|
||||||
|
#include "BLI_string.h"
|
||||||
|
|
||||||
#include "BKE_appdir.h"
|
#include "BKE_appdir.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
@@ -172,6 +173,8 @@ extern char datatoc_gpu_shader_gpencil_fill_frag_glsl[];
|
|||||||
/* cache of built-in shaders (each is created on first use) */
|
/* cache of built-in shaders (each is created on first use) */
|
||||||
static GPUShader *builtin_shaders[GPU_NUM_BUILTIN_SHADERS] = { NULL };
|
static GPUShader *builtin_shaders[GPU_NUM_BUILTIN_SHADERS] = { NULL };
|
||||||
|
|
||||||
|
static uint g_shaderid = 0;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *vert;
|
const char *vert;
|
||||||
const char *frag;
|
const char *frag;
|
||||||
@@ -272,7 +275,8 @@ GPUShader *GPU_shader_create(
|
|||||||
const char *fragcode,
|
const char *fragcode,
|
||||||
const char *geocode,
|
const char *geocode,
|
||||||
const char *libcode,
|
const char *libcode,
|
||||||
const char *defines)
|
const char *defines,
|
||||||
|
const char *shname)
|
||||||
{
|
{
|
||||||
return GPU_shader_create_ex(
|
return GPU_shader_create_ex(
|
||||||
vertexcode,
|
vertexcode,
|
||||||
@@ -283,7 +287,8 @@ GPUShader *GPU_shader_create(
|
|||||||
GPU_SHADER_FLAGS_NONE,
|
GPU_SHADER_FLAGS_NONE,
|
||||||
GPU_SHADER_TFB_NONE,
|
GPU_SHADER_TFB_NONE,
|
||||||
NULL,
|
NULL,
|
||||||
0);
|
0,
|
||||||
|
shname);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEBUG_SHADER_NONE ""
|
#define DEBUG_SHADER_NONE ""
|
||||||
@@ -342,7 +347,8 @@ GPUShader *GPU_shader_create_ex(
|
|||||||
const int flags,
|
const int flags,
|
||||||
const GPUShaderTFBType tf_type,
|
const GPUShaderTFBType tf_type,
|
||||||
const char **tf_names,
|
const char **tf_names,
|
||||||
const int tf_count)
|
const int tf_count,
|
||||||
|
const char *shname)
|
||||||
{
|
{
|
||||||
#ifdef WITH_OPENSUBDIV
|
#ifdef WITH_OPENSUBDIV
|
||||||
bool use_opensubdiv = (flags & GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV) != 0;
|
bool use_opensubdiv = (flags & GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV) != 0;
|
||||||
@@ -360,6 +366,12 @@ GPUShader *GPU_shader_create_ex(
|
|||||||
shader = MEM_callocN(sizeof(GPUShader), "GPUShader");
|
shader = MEM_callocN(sizeof(GPUShader), "GPUShader");
|
||||||
gpu_dump_shaders(NULL, 0, DEBUG_SHADER_NONE);
|
gpu_dump_shaders(NULL, 0, DEBUG_SHADER_NONE);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
BLI_snprintf(shader->name, sizeof(shader->name), "%s_%u", shname, g_shaderid++);
|
||||||
|
#else
|
||||||
|
UNUSED_VARS(shname);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (vertexcode)
|
if (vertexcode)
|
||||||
shader->vertex = glCreateShader(GL_VERTEX_SHADER);
|
shader->vertex = glCreateShader(GL_VERTEX_SHADER);
|
||||||
if (fragcode)
|
if (fragcode)
|
||||||
@@ -969,7 +981,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* common case */
|
/* common case */
|
||||||
builtin_shaders[shader] = GPU_shader_create(stages->vert, stages->frag, stages->geom, NULL, defines);
|
builtin_shaders[shader] = GPU_shader_create(stages->vert, stages->frag, stages->geom, NULL, defines, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builtin_shaders[shader];
|
return builtin_shaders[shader];
|
||||||
|
@@ -38,6 +38,9 @@ struct GPUShader {
|
|||||||
GPUShaderInterface *interface; /* cached uniform & attrib interface for shader */
|
GPUShaderInterface *interface; /* cached uniform & attrib interface for shader */
|
||||||
|
|
||||||
int feedback_transform_type;
|
int feedback_transform_type;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
char name[64];
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __GPU_SHADER_PRIVATE_H__ */
|
#endif /* __GPU_SHADER_PRIVATE_H__ */
|
||||||
|
Reference in New Issue
Block a user