forked from blender/blender
me-main #1
@ -523,19 +523,18 @@ void DebugDraw::display_lines()
|
||||
GPUBatch *batch = drw_cache_procedural_lines_get();
|
||||
GPUShader *shader = DRW_shader_debug_draw_display_get();
|
||||
GPU_batch_set_shader(batch, shader);
|
||||
int slot = GPU_shader_get_builtin_ssbo(shader, GPU_STORAGE_BUFFER_DEBUG_VERTS);
|
||||
GPU_shader_uniform_mat4(shader, "persmat", persmat.ptr());
|
||||
|
||||
if (gpu_draw_buf_used) {
|
||||
GPU_debug_group_begin("GPU");
|
||||
GPU_storagebuf_bind(gpu_draw_buf_, slot);
|
||||
GPU_storagebuf_bind(gpu_draw_buf_, DRW_DEBUG_DRAW_SLOT);
|
||||
GPU_batch_draw_indirect(batch, gpu_draw_buf_, 0);
|
||||
GPU_storagebuf_unbind(gpu_draw_buf_);
|
||||
GPU_debug_group_end();
|
||||
}
|
||||
|
||||
GPU_debug_group_begin("CPU");
|
||||
GPU_storagebuf_bind(cpu_draw_buf_, slot);
|
||||
GPU_storagebuf_bind(cpu_draw_buf_, DRW_DEBUG_DRAW_SLOT);
|
||||
GPU_batch_draw_indirect(batch, cpu_draw_buf_, 0);
|
||||
GPU_storagebuf_unbind(cpu_draw_buf_);
|
||||
GPU_debug_group_end();
|
||||
@ -556,21 +555,20 @@ void DebugDraw::display_prints()
|
||||
GPUBatch *batch = drw_cache_procedural_points_get();
|
||||
GPUShader *shader = DRW_shader_debug_print_display_get();
|
||||
GPU_batch_set_shader(batch, shader);
|
||||
int slot = GPU_shader_get_builtin_ssbo(shader, GPU_STORAGE_BUFFER_DEBUG_PRINT);
|
||||
float f_viewport[4];
|
||||
GPU_viewport_size_get_f(f_viewport);
|
||||
GPU_shader_uniform_2fv(shader, "viewport_size", &f_viewport[2]);
|
||||
|
||||
if (gpu_print_buf_used) {
|
||||
GPU_debug_group_begin("GPU");
|
||||
GPU_storagebuf_bind(gpu_print_buf_, slot);
|
||||
GPU_storagebuf_bind(gpu_print_buf_, DRW_DEBUG_PRINT_SLOT);
|
||||
GPU_batch_draw_indirect(batch, gpu_print_buf_, 0);
|
||||
GPU_storagebuf_unbind(gpu_print_buf_);
|
||||
GPU_debug_group_end();
|
||||
}
|
||||
|
||||
GPU_debug_group_begin("CPU");
|
||||
GPU_storagebuf_bind(cpu_print_buf_, slot);
|
||||
GPU_storagebuf_bind(cpu_print_buf_, DRW_DEBUG_PRINT_SLOT);
|
||||
GPU_batch_draw_indirect(batch, cpu_print_buf_, 0);
|
||||
GPU_storagebuf_unbind(cpu_print_buf_);
|
||||
GPU_debug_group_end();
|
||||
|
@ -1719,36 +1719,6 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
|
||||
1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* TODO(Metal): Support Shader debug print.
|
||||
* This is not currently supported by Metal Backend. */
|
||||
if (GPU_backend_get_type() != GPU_BACKEND_METAL) {
|
||||
int debug_print_location = GPU_shader_get_builtin_ssbo(shader, GPU_STORAGE_BUFFER_DEBUG_PRINT);
|
||||
if (debug_print_location != -1) {
|
||||
GPUStorageBuf *buf = drw_debug_gpu_print_buf_get();
|
||||
drw_shgroup_uniform_create_ex(shgroup,
|
||||
debug_print_location,
|
||||
DRW_UNIFORM_STORAGE_BLOCK,
|
||||
buf,
|
||||
GPU_SAMPLER_DEFAULT,
|
||||
0,
|
||||
1);
|
||||
# ifndef DISABLE_DEBUG_SHADER_PRINT_BARRIER
|
||||
/* Add a barrier to allow multiple shader writing to the same buffer. */
|
||||
DRW_shgroup_barrier(shgroup, GPU_BARRIER_SHADER_STORAGE);
|
||||
# endif
|
||||
}
|
||||
|
||||
int debug_draw_location = GPU_shader_get_builtin_ssbo(shader, GPU_STORAGE_BUFFER_DEBUG_VERTS);
|
||||
if (debug_draw_location != -1) {
|
||||
GPUStorageBuf *buf = drw_debug_gpu_draw_buf_get();
|
||||
drw_shgroup_uniform_create_ex(
|
||||
shgroup, debug_draw_location, DRW_UNIFORM_STORAGE_BLOCK, buf, GPU_SAMPLER_DEFAULT, 0, 1);
|
||||
/* NOTE(fclem): No barrier as ordering is not important. */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Not supported. */
|
||||
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW_INV) == -1);
|
||||
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW) == -1);
|
||||
|
@ -18,7 +18,7 @@ GPU_SHADER_INTERFACE_INFO(draw_debug_print_display_iface, "").flat(Type::UINT, "
|
||||
GPU_SHADER_CREATE_INFO(draw_debug_print_display)
|
||||
.do_static_compilation(true)
|
||||
.typedef_source("draw_shader_shared.h")
|
||||
.storage_buf(7, Qualifier::READ, "uint", "drw_debug_print_buf[]")
|
||||
.storage_buf(DRW_DEBUG_PRINT_SLOT, Qualifier::READ, "uint", "drw_debug_print_buf[]")
|
||||
.vertex_out(draw_debug_print_display_iface)
|
||||
.fragment_out(0, Type::VEC4, "out_color")
|
||||
.push_constant(Type::VEC2, "viewport_size")
|
||||
@ -46,7 +46,7 @@ GPU_SHADER_INTERFACE_INFO(draw_debug_draw_display_iface, "interp").flat(Type::VE
|
||||
GPU_SHADER_CREATE_INFO(draw_debug_draw_display)
|
||||
.do_static_compilation(true)
|
||||
.typedef_source("draw_shader_shared.h")
|
||||
.storage_buf(6, Qualifier::READ, "DRWDebugVert", "drw_debug_verts_buf[]")
|
||||
.storage_buf(DRW_DEBUG_DRAW_SLOT, Qualifier::READ, "DRWDebugVert", "drw_debug_verts_buf[]")
|
||||
.vertex_out(draw_debug_draw_display_iface)
|
||||
.fragment_out(0, Type::VEC4, "out_color")
|
||||
.push_constant(Type::MAT4, "persmat")
|
||||
|
@ -270,17 +270,6 @@ typedef enum {
|
||||
/** DEPRECATED: Use hardcoded buffer location instead. */
|
||||
int GPU_shader_get_builtin_block(GPUShader *shader, int builtin);
|
||||
|
||||
/** DEPRECATED: Use hardcoded buffer location instead. */
|
||||
typedef enum {
|
||||
GPU_STORAGE_BUFFER_DEBUG_VERTS = 0, /* drw_debug_verts_buf */
|
||||
GPU_STORAGE_BUFFER_DEBUG_PRINT, /* drw_debug_print_buf */
|
||||
|
||||
GPU_NUM_STORAGE_BUFFERS, /* Special value, denotes number of builtin buffer blocks. */
|
||||
} GPUStorageBufferBuiltin;
|
||||
|
||||
/** DEPRECATED: Use hardcoded buffer location instead. */
|
||||
int GPU_shader_get_builtin_ssbo(GPUShader *shader, int builtin);
|
||||
|
||||
/** DEPRECATED: Kept only because of Python GPU API. */
|
||||
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name);
|
||||
|
||||
|
@ -543,12 +543,6 @@ int GPU_shader_get_builtin_block(GPUShader *shader, int builtin)
|
||||
return interface->ubo_builtin((GPUUniformBlockBuiltin)builtin);
|
||||
}
|
||||
|
||||
int GPU_shader_get_builtin_ssbo(GPUShader *shader, int builtin)
|
||||
{
|
||||
const ShaderInterface *interface = unwrap(shader)->interface;
|
||||
return interface->ssbo_builtin((GPUStorageBufferBuiltin)builtin);
|
||||
}
|
||||
|
||||
int GPU_shader_get_ssbo_binding(GPUShader *shader, const char *name)
|
||||
{
|
||||
const ShaderInterface *interface = unwrap(shader)->interface;
|
||||
|
@ -57,7 +57,6 @@ class ShaderInterface {
|
||||
/** Location of builtin uniforms. Fast access, no lookup needed. */
|
||||
int32_t builtins_[GPU_NUM_UNIFORMS];
|
||||
int32_t builtin_blocks_[GPU_NUM_UNIFORM_BLOCKS];
|
||||
int32_t builtin_buffers_[GPU_NUM_STORAGE_BUFFERS];
|
||||
|
||||
/**
|
||||
* Currently only used for `GPU_shader_get_attribute_info`.
|
||||
@ -128,17 +127,9 @@ class ShaderInterface {
|
||||
return builtin_blocks_[builtin];
|
||||
}
|
||||
|
||||
/* Returns binding position. */
|
||||
inline int32_t ssbo_builtin(const GPUStorageBufferBuiltin builtin) const
|
||||
{
|
||||
BLI_assert(builtin >= 0 && builtin < GPU_NUM_STORAGE_BUFFERS);
|
||||
return builtin_buffers_[builtin];
|
||||
}
|
||||
|
||||
protected:
|
||||
static inline const char *builtin_uniform_name(GPUUniformBuiltin u);
|
||||
static inline const char *builtin_uniform_block_name(GPUUniformBlockBuiltin u);
|
||||
static inline const char *builtin_storage_block_name(GPUStorageBufferBuiltin u);
|
||||
|
||||
inline uint32_t set_input_name(ShaderInput *input, char *name, uint32_t name_len) const;
|
||||
inline void copy_input_name(ShaderInput *input,
|
||||
@ -234,18 +225,6 @@ inline const char *ShaderInterface::builtin_uniform_block_name(GPUUniformBlockBu
|
||||
}
|
||||
}
|
||||
|
||||
inline const char *ShaderInterface::builtin_storage_block_name(GPUStorageBufferBuiltin u)
|
||||
{
|
||||
switch (u) {
|
||||
case GPU_STORAGE_BUFFER_DEBUG_VERTS:
|
||||
return "drw_debug_verts_buf";
|
||||
case GPU_STORAGE_BUFFER_DEBUG_PRINT:
|
||||
return "drw_debug_print_buf";
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns string length including '\0' terminator. */
|
||||
inline uint32_t ShaderInterface::set_input_name(ShaderInput *input,
|
||||
char *name,
|
||||
|
@ -371,13 +371,6 @@ GLShaderInterface::GLShaderInterface(GLuint program)
|
||||
builtin_blocks_[u] = (block != nullptr) ? block->binding : -1;
|
||||
}
|
||||
|
||||
/* Builtin Storage Buffers */
|
||||
for (int32_t u_int = 0; u_int < GPU_NUM_STORAGE_BUFFERS; u_int++) {
|
||||
GPUStorageBufferBuiltin u = static_cast<GPUStorageBufferBuiltin>(u_int);
|
||||
const ShaderInput *block = this->ssbo_get(builtin_storage_block_name(u));
|
||||
builtin_buffers_[u] = (block != nullptr) ? block->binding : -1;
|
||||
}
|
||||
|
||||
MEM_freeN(uniforms_from_blocks);
|
||||
|
||||
/* Resize name buffer to save some memory. */
|
||||
@ -550,13 +543,6 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI
|
||||
builtin_blocks_[u] = (block != nullptr) ? block->binding : -1;
|
||||
}
|
||||
|
||||
/* Builtin Storage Buffers */
|
||||
for (int32_t u_int = 0; u_int < GPU_NUM_STORAGE_BUFFERS; u_int++) {
|
||||
GPUStorageBufferBuiltin u = static_cast<GPUStorageBufferBuiltin>(u_int);
|
||||
const ShaderInput *block = this->ssbo_get(builtin_storage_block_name(u));
|
||||
builtin_buffers_[u] = (block != nullptr) ? block->binding : -1;
|
||||
}
|
||||
|
||||
this->sort_inputs();
|
||||
|
||||
// this->debug_print();
|
||||
|
Loading…
Reference in New Issue
Block a user