DRW: Add DRW_UNUSED_RESOURCE_TRACKING for ubo and ssbo
When uncommented, this option will make any call binding a resource that is not present in the shader produce a warning message with its origin.
This commit is contained in:
@@ -66,6 +66,15 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Uncomment to track unused resource bindings. */
|
||||
// #define DRW_UNUSED_RESOURCE_TRACKING
|
||||
|
||||
#ifdef DRW_UNUSED_RESOURCE_TRACKING
|
||||
# define DRW_DEBUG_FILE_LINE_ARGS , const char *file, int line
|
||||
#else
|
||||
# define DRW_DEBUG_FILE_LINE_ARGS
|
||||
#endif
|
||||
|
||||
struct GPUBatch;
|
||||
struct GPUMaterial;
|
||||
struct GPUShader;
|
||||
@@ -568,12 +577,12 @@ void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup,
|
||||
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUTexture **tex);
|
||||
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const struct GPUUniformBuf *ubo);
|
||||
void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUUniformBuf **ubo);
|
||||
void DRW_shgroup_uniform_block_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const struct GPUUniformBuf *ubo DRW_DEBUG_FILE_LINE_ARGS);
|
||||
void DRW_shgroup_uniform_block_ref_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUUniformBuf **ubo DRW_DEBUG_FILE_LINE_ARGS);
|
||||
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const float *value,
|
||||
@@ -633,12 +642,32 @@ void DRW_shgroup_uniform_vec4_array_copy(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const float (*value)[4],
|
||||
int arraysize);
|
||||
void DRW_shgroup_vertex_buffer(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUVertBuf *vertex_buffer);
|
||||
void DRW_shgroup_vertex_buffer_ref(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUVertBuf **vertex_buffer);
|
||||
void DRW_shgroup_vertex_buffer_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUVertBuf *vertex_buffer DRW_DEBUG_FILE_LINE_ARGS);
|
||||
void DRW_shgroup_vertex_buffer_ref_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUVertBuf **vertex_buffer DRW_DEBUG_FILE_LINE_ARGS);
|
||||
|
||||
#ifdef DRW_UNUSED_RESOURCE_TRACKING
|
||||
# define DRW_shgroup_vertex_buffer(shgroup, name, vert) \
|
||||
DRW_shgroup_vertex_buffer_ex(shgroup, name, vert, __FILE__, __LINE__)
|
||||
# define DRW_shgroup_vertex_buffer_ref(shgroup, name, vert) \
|
||||
DRW_shgroup_vertex_buffer_ref_ex(shgroup, name, vert, __FILE__, __LINE__)
|
||||
# define DRW_shgroup_uniform_block(shgroup, name, ubo) \
|
||||
DRW_shgroup_uniform_block_ex(shgroup, name, ubo, __FILE__, __LINE__)
|
||||
# define DRW_shgroup_uniform_block_ref(shgroup, name, ubo) \
|
||||
DRW_shgroup_uniform_block_ref_ex(shgroup, name, ubo, __FILE__, __LINE__)
|
||||
#else
|
||||
# define DRW_shgroup_vertex_buffer(shgroup, name, vert) \
|
||||
DRW_shgroup_vertex_buffer_ex(shgroup, name, vert)
|
||||
# define DRW_shgroup_vertex_buffer_ref(shgroup, name, vert) \
|
||||
DRW_shgroup_vertex_buffer_ref_ex(shgroup, name, vert)
|
||||
# define DRW_shgroup_uniform_block(shgroup, name, ubo) \
|
||||
DRW_shgroup_uniform_block_ex(shgroup, name, ubo)
|
||||
# define DRW_shgroup_uniform_block_ref(shgroup, name, ubo) \
|
||||
DRW_shgroup_uniform_block_ref_ex(shgroup, name, ubo)
|
||||
#endif
|
||||
|
||||
bool DRW_shgroup_is_empty(DRWShadingGroup *shgroup);
|
||||
|
||||
|
||||
@@ -283,19 +283,45 @@ void DRW_shgroup_uniform_image_ref(DRWShadingGroup *shgroup, const char *name, G
|
||||
drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_IMAGE_REF, tex, 0, 0, 1);
|
||||
}
|
||||
|
||||
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const GPUUniformBuf *ubo)
|
||||
void DRW_shgroup_uniform_block_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const GPUUniformBuf *ubo DRW_DEBUG_FILE_LINE_ARGS)
|
||||
{
|
||||
BLI_assert(ubo != NULL);
|
||||
int loc = GPU_shader_get_uniform_block_binding(shgroup->shader, name);
|
||||
if (loc == -1) {
|
||||
#ifdef DRW_UNUSED_RESOURCE_TRACKING
|
||||
printf("%s:%d: Unable to locate binding of shader uniform buffer object: %s.\n",
|
||||
file,
|
||||
line,
|
||||
name);
|
||||
#else
|
||||
/* TODO(@fclem): Would be good to have, but eevee has too much of this for the moment. */
|
||||
// BLI_assert_msg(0, "Unable to locate binding of shader uniform buffer objects.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_BLOCK, ubo, 0, 0, 1);
|
||||
}
|
||||
|
||||
void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup, const char *name, GPUUniformBuf **ubo)
|
||||
void DRW_shgroup_uniform_block_ref_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
GPUUniformBuf **ubo DRW_DEBUG_FILE_LINE_ARGS)
|
||||
{
|
||||
BLI_assert(ubo != NULL);
|
||||
int loc = GPU_shader_get_uniform_block_binding(shgroup->shader, name);
|
||||
if (loc == -1) {
|
||||
#ifdef DRW_UNUSED_RESOURCE_TRACKING
|
||||
printf("%s:%d: Unable to locate binding of shader uniform buffer object: %s.\n",
|
||||
file,
|
||||
line,
|
||||
name);
|
||||
#else
|
||||
/* TODO(@fclem): Would be good to have, but eevee has too much of this for the moment. */
|
||||
// BLI_assert_msg(0, "Unable to locate binding of shader uniform buffer objects.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_BLOCK_REF, ubo, 0, 0, 1);
|
||||
}
|
||||
|
||||
@@ -447,26 +473,40 @@ void DRW_shgroup_uniform_vec4_array_copy(DRWShadingGroup *shgroup,
|
||||
}
|
||||
}
|
||||
|
||||
void DRW_shgroup_vertex_buffer(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
GPUVertBuf *vertex_buffer)
|
||||
void DRW_shgroup_vertex_buffer_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
GPUVertBuf *vertex_buffer DRW_DEBUG_FILE_LINE_ARGS)
|
||||
{
|
||||
int location = GPU_shader_get_ssbo(shgroup->shader, name);
|
||||
if (location == -1) {
|
||||
#ifdef DRW_UNUSED_RESOURCE_TRACKING
|
||||
printf("%s:%d: Unable to locate binding of shader storage buffer object: %s.\n",
|
||||
file,
|
||||
line,
|
||||
name);
|
||||
#else
|
||||
BLI_assert_msg(0, "Unable to locate binding of shader storage buffer objects.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
drw_shgroup_uniform_create_ex(
|
||||
shgroup, location, DRW_UNIFORM_VERTEX_BUFFER_AS_STORAGE, vertex_buffer, 0, 0, 1);
|
||||
}
|
||||
|
||||
void DRW_shgroup_vertex_buffer_ref(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
GPUVertBuf **vertex_buffer)
|
||||
void DRW_shgroup_vertex_buffer_ref_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
GPUVertBuf **vertex_buffer DRW_DEBUG_FILE_LINE_ARGS)
|
||||
{
|
||||
int location = GPU_shader_get_ssbo(shgroup->shader, name);
|
||||
if (location == -1) {
|
||||
#ifdef DRW_UNUSED_RESOURCE_TRACKING
|
||||
printf("%s:%d: Unable to locate binding of shader storage buffer object: %s.\n",
|
||||
file,
|
||||
line,
|
||||
name);
|
||||
#else
|
||||
BLI_assert_msg(0, "Unable to locate binding of shader storage buffer objects.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
drw_shgroup_uniform_create_ex(
|
||||
|
||||
Reference in New Issue
Block a user