Gizmo: press shift key to scale area lights uniformly #104418

Closed
Weizhen Huang wants to merge 13 commits from weizhen:shift_uniform_scale into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
27 changed files with 98 additions and 101 deletions
Showing only changes of commit 3b0c887835 - Show all commits

View File

@ -41,10 +41,10 @@ static float *parallel_reduction_dispatch(Context &context,
GPUTexture *reduced_texture = context.texture_pool().acquire(reduced_size, format);
GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH);
const int texture_image_unit = GPU_shader_get_texture_binding(shader, "input_tx");
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
GPU_texture_bind(texture_to_reduce, texture_image_unit);
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(reduced_texture, image_unit);
GPU_compute_dispatch(shader, reduced_size.x, reduced_size.y, 1);

View File

@ -135,7 +135,7 @@ void MorphologicalDistanceFeatherWeights::compute_distance_falloffs(int type, in
void MorphologicalDistanceFeatherWeights::bind_weights_as_texture(GPUShader *shader,
const char *texture_name) const
{
const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, texture_name);
GPU_texture_bind(weights_texture_, texture_image_unit);
}
@ -147,7 +147,7 @@ void MorphologicalDistanceFeatherWeights::unbind_weights_as_texture() const
void MorphologicalDistanceFeatherWeights::bind_distance_falloffs_as_texture(
GPUShader *shader, const char *texture_name) const
{
const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, texture_name);
GPU_texture_bind(distance_falloffs_texture_, texture_image_unit);
}

View File

@ -103,7 +103,7 @@ SymmetricBlurWeights::~SymmetricBlurWeights()
void SymmetricBlurWeights::bind_as_texture(GPUShader *shader, const char *texture_name) const
{
const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, texture_name);
GPU_texture_bind(texture_, texture_image_unit);
}

View File

@ -81,7 +81,7 @@ SymmetricSeparableBlurWeights::~SymmetricSeparableBlurWeights()
void SymmetricSeparableBlurWeights::bind_as_texture(GPUShader *shader,
const char *texture_name) const
{
const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, texture_name);
GPU_texture_bind(texture_, texture_image_unit);
}

View File

@ -82,7 +82,7 @@ void Result::bind_as_texture(GPUShader *shader, const char *texture_name) const
/* Make sure any prior writes to the texture are reflected before reading from it. */
GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH);
const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, texture_name);
GPU_texture_bind(texture_, texture_image_unit);
}
@ -93,7 +93,7 @@ void Result::bind_as_image(GPUShader *shader, const char *image_name, bool read)
GPU_memory_barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS);
}
const int image_unit = GPU_shader_get_texture_binding(shader, image_name);
const int image_unit = GPU_shader_get_sampler_binding(shader, image_name);
GPU_texture_image_bind(texture_, image_unit);
}

View File

@ -95,14 +95,14 @@ void ShaderOperation::bind_material_resources(GPUShader *shader)
* no uniforms. */
GPUUniformBuf *ubo = GPU_material_uniform_buffer_get(material_);
if (ubo) {
GPU_uniformbuf_bind(ubo, GPU_shader_get_uniform_block_binding(shader, GPU_UBO_BLOCK_NAME));
GPU_uniformbuf_bind(ubo, GPU_shader_get_ubo_binding(shader, GPU_UBO_BLOCK_NAME));
}
/* Bind color band textures needed by curve and ramp nodes. */
ListBase textures = GPU_material_textures(material_);
LISTBASE_FOREACH (GPUMaterialTexture *, texture, &textures) {
if (texture->colorband) {
const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture->sampler_name);
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, texture->sampler_name);
GPU_texture_bind(*texture->colorband, texture_image_unit);
}
}

View File

@ -259,17 +259,16 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds,
GPU_shader_uniform_1i(shader, "visibility_word_per_draw", word_per_draw);
GPU_shader_uniform_1b(shader, "force_fail_method", force_fail_method_);
GPU_shader_uniform_3fv(shader, "shadow_direction", light_direction_);
GPU_uniformbuf_bind(extruded_frustum_,
GPU_shader_get_uniform_block_binding(shader, "extruded_frustum"));
GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo(shader, "bounds_buf"));
GPU_uniformbuf_bind(extruded_frustum_, GPU_shader_get_ubo_binding(shader, "extruded_frustum"));
GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo_binding(shader, "bounds_buf"));
if (current_pass_type_ == ShadowPass::FORCED_FAIL) {
GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo(shader, "visibility_buf"));
GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo_binding(shader, "visibility_buf"));
}
else {
GPU_storagebuf_bind(pass_visibility_buf_,
GPU_shader_get_ssbo(shader, "pass_visibility_buf"));
GPU_shader_get_ssbo_binding(shader, "pass_visibility_buf"));
GPU_storagebuf_bind(fail_visibility_buf_,
GPU_shader_get_ssbo(shader, "fail_visibility_buf"));
GPU_shader_get_ssbo_binding(shader, "fail_visibility_buf"));
}
GPU_uniformbuf_bind(data_, DRW_VIEW_UBO_SLOT);
GPU_compute_dispatch(shader, divide_ceil_u(resource_len, DRW_VISIBILITY_GROUP_SIZE), 1, 1);

View File

@ -1350,7 +1350,7 @@ static void draw_subdiv_ubo_update_and_bind(const DRWSubdivCache *cache,
GPU_uniformbuf_update(cache->ubo, &storage);
const int binding = GPU_shader_get_uniform_block_binding(shader, "shader_data");
const int binding = GPU_shader_get_ubo_binding(shader, "shader_data");
GPU_uniformbuf_bind(cache->ubo, binding);
}

View File

@ -646,10 +646,10 @@ void DrawMultiBuf::bind(RecordingState &state,
GPU_shader_uniform_1i(shader, "prototype_len", prototype_count_);
GPU_shader_uniform_1i(shader, "visibility_word_per_draw", visibility_word_per_draw);
GPU_shader_uniform_1i(shader, "view_shift", log2_ceil_u(view_len));
GPU_storagebuf_bind(group_buf_, GPU_shader_get_ssbo(shader, "group_buf"));
GPU_storagebuf_bind(visibility_buf, GPU_shader_get_ssbo(shader, "visibility_buf"));
GPU_storagebuf_bind(prototype_buf_, GPU_shader_get_ssbo(shader, "prototype_buf"));
GPU_storagebuf_bind(command_buf_, GPU_shader_get_ssbo(shader, "command_buf"));
GPU_storagebuf_bind(group_buf_, GPU_shader_get_ssbo_binding(shader, "group_buf"));
GPU_storagebuf_bind(visibility_buf, GPU_shader_get_ssbo_binding(shader, "visibility_buf"));
GPU_storagebuf_bind(prototype_buf_, GPU_shader_get_ssbo_binding(shader, "prototype_buf"));
GPU_storagebuf_bind(command_buf_, GPU_shader_get_ssbo_binding(shader, "command_buf"));
GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
GPU_compute_dispatch(shader, divide_ceil_u(prototype_count_, DRW_COMMAND_GROUP_SIZE), 1, 1);
if (GPU_shader_draw_parameters_support() == false) {

View File

@ -114,9 +114,9 @@ void Manager::end_sync()
GPUShader *shader = DRW_shader_draw_resource_finalize_get();
GPU_shader_bind(shader);
GPU_shader_uniform_1i(shader, "resource_len", resource_len_);
GPU_storagebuf_bind(matrix_buf.current(), GPU_shader_get_ssbo(shader, "matrix_buf"));
GPU_storagebuf_bind(bounds_buf.current(), GPU_shader_get_ssbo(shader, "bounds_buf"));
GPU_storagebuf_bind(infos_buf.current(), GPU_shader_get_ssbo(shader, "infos_buf"));
GPU_storagebuf_bind(matrix_buf.current(), GPU_shader_get_ssbo_binding(shader, "matrix_buf"));
GPU_storagebuf_bind(bounds_buf.current(), GPU_shader_get_ssbo_binding(shader, "bounds_buf"));
GPU_storagebuf_bind(infos_buf.current(), GPU_shader_get_ssbo_binding(shader, "infos_buf"));
GPU_compute_dispatch(shader, thread_groups, 1, 1);
GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE);

View File

@ -256,7 +256,7 @@ void DRW_shgroup_uniform_texture_ex(DRWShadingGroup *shgroup,
eGPUSamplerState sampler_state)
{
BLI_assert(tex != nullptr);
int loc = GPU_shader_get_texture_binding(shgroup->shader, name);
int loc = GPU_shader_get_sampler_binding(shgroup->shader, name);
drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_TEXTURE, tex, sampler_state, 0, 1);
}
@ -271,7 +271,7 @@ void DRW_shgroup_uniform_texture_ref_ex(DRWShadingGroup *shgroup,
eGPUSamplerState sampler_state)
{
BLI_assert(tex != nullptr);
int loc = GPU_shader_get_texture_binding(shgroup->shader, name);
int loc = GPU_shader_get_sampler_binding(shgroup->shader, name);
drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_TEXTURE_REF, tex, sampler_state, 0, 1);
}
@ -283,14 +283,14 @@ void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name,
void DRW_shgroup_uniform_image(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
{
BLI_assert(tex != nullptr);
int loc = GPU_shader_get_texture_binding(shgroup->shader, name);
int loc = GPU_shader_get_sampler_binding(shgroup->shader, name);
drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_IMAGE, tex, GPU_SAMPLER_DEFAULT, 0, 1);
}
void DRW_shgroup_uniform_image_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
{
BLI_assert(tex != nullptr);
int loc = GPU_shader_get_texture_binding(shgroup->shader, name);
int loc = GPU_shader_get_sampler_binding(shgroup->shader, name);
drw_shgroup_uniform_create_ex(
shgroup, loc, DRW_UNIFORM_IMAGE_REF, tex, GPU_SAMPLER_DEFAULT, 0, 1);
}
@ -300,7 +300,7 @@ void DRW_shgroup_uniform_block_ex(DRWShadingGroup *shgroup,
const GPUUniformBuf *ubo DRW_DEBUG_FILE_LINE_ARGS)
{
BLI_assert(ubo != nullptr);
int loc = GPU_shader_get_uniform_block_binding(shgroup->shader, name);
int loc = GPU_shader_get_ubo_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",
@ -321,7 +321,7 @@ void DRW_shgroup_uniform_block_ref_ex(DRWShadingGroup *shgroup,
GPUUniformBuf **ubo DRW_DEBUG_FILE_LINE_ARGS)
{
BLI_assert(ubo != nullptr);
int loc = GPU_shader_get_uniform_block_binding(shgroup->shader, name);
int loc = GPU_shader_get_ubo_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",
@ -344,7 +344,7 @@ void DRW_shgroup_storage_block_ex(DRWShadingGroup *shgroup,
{
BLI_assert(ssbo != nullptr);
/* TODO(@fclem): Fix naming inconsistency. */
int loc = GPU_shader_get_ssbo(shgroup->shader, name);
int loc = GPU_shader_get_ssbo_binding(shgroup->shader, name);
if (loc == -1) {
#ifdef DRW_UNUSED_RESOURCE_TRACKING
printf("%s:%d: Unable to locate binding of shader storage buffer object: %s.\n",
@ -367,7 +367,7 @@ void DRW_shgroup_storage_block_ref_ex(DRWShadingGroup *shgroup,
{
BLI_assert(ssbo != nullptr);
/* TODO(@fclem): Fix naming inconsistency. */
int loc = GPU_shader_get_ssbo(shgroup->shader, name);
int loc = GPU_shader_get_ssbo_binding(shgroup->shader, name);
if (loc == -1) {
#ifdef DRW_UNUSED_RESOURCE_TRACKING
printf("%s:%d: Unable to locate binding of shader storage buffer object: %s.\n",
@ -539,7 +539,7 @@ 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);
int location = GPU_shader_get_ssbo_binding(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",
@ -564,7 +564,7 @@ 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);
int location = GPU_shader_get_ssbo_binding(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",
@ -589,7 +589,7 @@ void DRW_shgroup_buffer_texture(DRWShadingGroup *shgroup,
const char *name,
GPUVertBuf *vertex_buffer)
{
int location = GPU_shader_get_texture_binding(shgroup->shader, name);
int location = GPU_shader_get_sampler_binding(shgroup->shader, name);
if (location == -1) {
return;
}
@ -606,7 +606,7 @@ void DRW_shgroup_buffer_texture_ref(DRWShadingGroup *shgroup,
const char *name,
GPUVertBuf **vertex_buffer)
{
int location = GPU_shader_get_texture_binding(shgroup->shader, name);
int location = GPU_shader_get_sampler_binding(shgroup->shader, name);
if (location == -1) {
return;
}
@ -698,7 +698,7 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
drw_call_calc_orco(ob, ob_infos->orcotexfac);
/* Random float value. */
uint random = (DST.dupli_source) ?
DST.dupli_source->random_id :
DST.dupli_source->random_id :
/* TODO(fclem): this is rather costly to do at runtime. Maybe we can
* put it in ob->runtime and make depsgraph ensure it is up to date. */
BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0);
@ -1850,15 +1850,14 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, GPUMaterial *mater
const GPUUniformAttrList *uattrs = GPU_material_uniform_attributes(material);
if (uattrs != nullptr) {
int loc = GPU_shader_get_uniform_block_binding(grp->shader, GPU_ATTRIBUTE_UBO_BLOCK_NAME);
int loc = GPU_shader_get_ubo_binding(grp->shader, GPU_ATTRIBUTE_UBO_BLOCK_NAME);
drw_shgroup_uniform_create_ex(
grp, loc, DRW_UNIFORM_BLOCK_OBATTRS, uattrs, GPU_SAMPLER_DEFAULT, 0, 1);
grp->uniform_attrs = uattrs;
}
if (GPU_material_layer_attributes(material) != nullptr) {
int loc = GPU_shader_get_uniform_block_binding(grp->shader,
GPU_LAYER_ATTRIBUTE_UBO_BLOCK_NAME);
int loc = GPU_shader_get_ubo_binding(grp->shader, GPU_LAYER_ATTRIBUTE_UBO_BLOCK_NAME);
drw_shgroup_uniform_create_ex(
grp, loc, DRW_UNIFORM_BLOCK_VLATTRS, nullptr, GPU_SAMPLER_DEFAULT, 0, 1);
}

View File

@ -861,42 +861,42 @@ template<class T> inline int PassBase<T>::push_constant_offset(const char *name)
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUStorageBuf *buffer)
{
this->bind_ssbo(GPU_shader_get_ssbo(shader_, name), buffer);
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUUniformBuf *buffer)
{
this->bind_ssbo(GPU_shader_get_ssbo(shader_, name), buffer);
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUUniformBuf **buffer)
{
this->bind_ssbo(GPU_shader_get_ssbo(shader_, name), buffer);
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUVertBuf *buffer)
{
this->bind_ssbo(GPU_shader_get_ssbo(shader_, name), buffer);
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUVertBuf **buffer)
{
this->bind_ssbo(GPU_shader_get_ssbo(shader_, name), buffer);
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUIndexBuf *buffer)
{
this->bind_ssbo(GPU_shader_get_ssbo(shader_, name), buffer);
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUIndexBuf **buffer)
{
this->bind_ssbo(GPU_shader_get_ssbo(shader_, name), buffer);
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_ubo(const char *name, GPUUniformBuf *buffer)
{
this->bind_ubo(GPU_shader_get_uniform_block_binding(shader_, name), buffer);
this->bind_ubo(GPU_shader_get_ubo_binding(shader_, name), buffer);
}
template<class T>
@ -904,22 +904,22 @@ inline void PassBase<T>::bind_texture(const char *name,
GPUTexture *texture,
eGPUSamplerState state)
{
this->bind_texture(GPU_shader_get_texture_binding(shader_, name), texture, state);
this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), texture, state);
}
template<class T> inline void PassBase<T>::bind_texture(const char *name, GPUVertBuf *buffer)
{
this->bind_texture(GPU_shader_get_texture_binding(shader_, name), buffer);
this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_texture(const char *name, GPUVertBuf **buffer)
{
this->bind_texture(GPU_shader_get_texture_binding(shader_, name), buffer);
this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_image(const char *name, GPUTexture *image)
{
this->bind_image(GPU_shader_get_texture_binding(shader_, name), image);
this->bind_image(GPU_shader_get_sampler_binding(shader_, name), image);
}
template<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUStorageBuf *buffer)
@ -991,12 +991,12 @@ template<class T> inline void PassBase<T>::bind_image(int slot, GPUTexture *imag
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUStorageBuf **buffer)
{
this->bind_ssbo(GPU_shader_get_ssbo(shader_, name), buffer);
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
}
template<class T> inline void PassBase<T>::bind_ubo(const char *name, GPUUniformBuf **buffer)
{
this->bind_ubo(GPU_shader_get_uniform_block_binding(shader_, name), buffer);
this->bind_ubo(GPU_shader_get_ubo_binding(shader_, name), buffer);
}
template<class T>
@ -1004,12 +1004,12 @@ inline void PassBase<T>::bind_texture(const char *name,
GPUTexture **texture,
eGPUSamplerState state)
{
this->bind_texture(GPU_shader_get_texture_binding(shader_, name), texture, state);
this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), texture, state);
}
template<class T> inline void PassBase<T>::bind_image(const char *name, GPUTexture **image)
{
this->bind_image(GPU_shader_get_texture_binding(shader_, name), image);
this->bind_image(GPU_shader_get_sampler_binding(shader_, name), image);
}
template<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUStorageBuf **buffer)

View File

@ -244,7 +244,7 @@ void View::compute_procedural_bounds()
GPUShader *shader = DRW_shader_draw_view_finalize_get();
GPU_shader_bind(shader);
GPU_uniformbuf_bind_as_ssbo(culling_, GPU_shader_get_ssbo(shader, "view_culling_buf"));
GPU_uniformbuf_bind_as_ssbo(culling_, GPU_shader_get_ssbo_binding(shader, "view_culling_buf"));
GPU_uniformbuf_bind(data_, DRW_VIEW_UBO_SLOT);
GPU_compute_dispatch(shader, 1, 1, 1);
GPU_memory_barrier(GPU_BARRIER_UNIFORM);
@ -289,8 +289,8 @@ void View::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool d
GPU_shader_uniform_1i(shader, "resource_len", resource_len);
GPU_shader_uniform_1i(shader, "view_len", view_len_);
GPU_shader_uniform_1i(shader, "visibility_word_per_draw", word_per_draw);
GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo(shader, "bounds_buf"));
GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo(shader, "visibility_buf"));
GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo_binding(shader, "bounds_buf"));
GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo_binding(shader, "visibility_buf"));
GPU_uniformbuf_bind(frozen_ ? data_freeze_ : data_, DRW_VIEW_UBO_SLOT);
GPU_uniformbuf_bind(frozen_ ? culling_freeze_ : culling_, DRW_VIEW_CULLING_UBO_SLOT);
GPU_compute_dispatch(shader, divide_ceil_u(resource_len, DRW_VISIBILITY_GROUP_SIZE), 1, 1);

View File

@ -1620,12 +1620,12 @@ static void icon_draw_cache_texture_flush_ex(GPUTexture *texture,
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR);
GPU_shader_bind(shader);
const int data_binding = GPU_shader_get_uniform_block_binding(shader, "multi_rect_data");
const int data_binding = GPU_shader_get_ubo_binding(shader, "multi_rect_data");
GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(
sizeof(MultiRectCallData), texture_draw_calls->drawcall_cache, __func__);
GPU_uniformbuf_bind(ubo, data_binding);
const int img_binding = GPU_shader_get_texture_binding(shader, "image");
const int img_binding = GPU_shader_get_sampler_binding(shader, "image");
GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false);
GPUBatch *quad = GPU_batch_preset_quad();
@ -1797,7 +1797,7 @@ static void icon_draw_texture(float x,
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_ICON);
GPU_shader_bind(shader);
const int img_binding = GPU_shader_get_texture_binding(shader, "image");
const int img_binding = GPU_shader_get_sampler_binding(shader, "image");
const int color_loc = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR);
const int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
const int rect_geom_loc = GPU_shader_get_uniform(shader, "rect_geom");

View File

@ -263,9 +263,9 @@ void GPU_batch_program_set_imm_shader(GPUBatch *batch);
#define GPU_batch_uniform_mat4(batch, name, val) \
GPU_shader_uniform_mat4((batch)->shader, name, val);
#define GPU_batch_uniformbuf_bind(batch, name, ubo) \
GPU_uniformbuf_bind(ubo, GPU_shader_get_uniform_block_binding((batch)->shader, name));
GPU_uniformbuf_bind(ubo, GPU_shader_get_ubo_binding((batch)->shader, name));
#define GPU_batch_texture_bind(batch, name, tex) \
GPU_texture_bind(tex, GPU_shader_get_texture_binding((batch)->shader, name));
GPU_texture_bind(tex, GPU_shader_get_sampler_binding((batch)->shader, name));
/** \} */

View File

@ -112,12 +112,11 @@ const char *GPU_shader_get_name(GPUShader *shader);
/**
* Returns binding point location.
* Binding location are given to be set at compile time and immutable.
* Binding location are given to be set at shader compile time and immutable.
*/
/* TODO(fclem): Make naming consistent. ubo_binding, ssbo_binding */
int GPU_shader_get_uniform_block_binding(GPUShader *shader, const char *name);
int GPU_shader_get_texture_binding(GPUShader *shader, const char *name);
int GPU_shader_get_ssbo(GPUShader *shader, const char *name);
int GPU_shader_get_ubo_binding(GPUShader *shader, const char *name);
int GPU_shader_get_ssbo_binding(GPUShader *shader, const char *name);
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name);
/**
* Returns uniform location.

View File

@ -602,19 +602,19 @@ void immUniform1i(const char *name, int x)
void immBindTexture(const char *name, GPUTexture *tex)
{
int binding = GPU_shader_get_texture_binding(imm->shader, name);
int binding = GPU_shader_get_sampler_binding(imm->shader, name);
GPU_texture_bind(tex, binding);
}
void immBindTextureSampler(const char *name, GPUTexture *tex, eGPUSamplerState state)
{
int binding = GPU_shader_get_texture_binding(imm->shader, name);
int binding = GPU_shader_get_sampler_binding(imm->shader, name);
GPU_texture_bind_ex(tex, state, binding, true);
}
void immBindUniformBuf(const char *name, GPUUniformBuf *ubo)
{
int binding = GPU_shader_get_uniform_block_binding(imm->shader, name);
int binding = GPU_shader_get_ubo_binding(imm->shader, name);
GPU_uniformbuf_bind(ubo, binding);
}

View File

@ -549,7 +549,7 @@ int GPU_shader_get_builtin_ssbo(GPUShader *shader, int builtin)
return interface->ssbo_builtin((GPUStorageBufferBuiltin)builtin);
}
int GPU_shader_get_ssbo(GPUShader *shader, const char *name)
int GPU_shader_get_ssbo_binding(GPUShader *shader, const char *name)
{
const ShaderInterface *interface = unwrap(shader)->interface;
const ShaderInput *ssbo = interface->ssbo_get(name);
@ -563,14 +563,14 @@ int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)
return ubo ? ubo->location : -1;
}
int GPU_shader_get_uniform_block_binding(GPUShader *shader, const char *name)
int GPU_shader_get_ubo_binding(GPUShader *shader, const char *name)
{
const ShaderInterface *interface = unwrap(shader)->interface;
const ShaderInput *ubo = interface->ubo_get(name);
return ubo ? ubo->binding : -1;
}
int GPU_shader_get_texture_binding(GPUShader *shader, const char *name)
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
{
const ShaderInterface *interface = unwrap(shader)->interface;
const ShaderInput *tex = interface->uniform_get(name);

View File

@ -47,7 +47,7 @@ static void test_gpu_shader_compute_2d()
EXPECT_NE(texture, nullptr);
GPU_shader_bind(shader);
GPU_texture_image_bind(texture, GPU_shader_get_texture_binding(shader, "img_output"));
GPU_texture_image_bind(texture, GPU_shader_get_sampler_binding(shader, "img_output"));
/* Dispatch compute task. */
GPU_compute_dispatch(shader, SIZE, SIZE, 1);
@ -93,7 +93,7 @@ static void test_gpu_shader_compute_1d()
EXPECT_NE(texture, nullptr);
GPU_shader_bind(shader);
GPU_texture_image_bind(texture, GPU_shader_get_texture_binding(shader, "img_output"));
GPU_texture_image_bind(texture, GPU_shader_get_sampler_binding(shader, "img_output"));
/* Dispatch compute task. */
GPU_compute_dispatch(shader, SIZE, 1, 1);
@ -142,7 +142,7 @@ static void test_gpu_shader_compute_vbo()
GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
GPUVertBuf *vbo = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_DEVICE_ONLY);
GPU_vertbuf_data_alloc(vbo, SIZE);
GPU_vertbuf_bind_as_ssbo(vbo, GPU_shader_get_ssbo(shader, "out_positions"));
GPU_vertbuf_bind_as_ssbo(vbo, GPU_shader_get_ssbo_binding(shader, "out_positions"));
/* Dispatch compute task. */
GPU_compute_dispatch(shader, SIZE, 1, 1);
@ -186,7 +186,7 @@ static void test_gpu_shader_compute_ibo()
/* Construct IBO. */
GPUIndexBuf *ibo = GPU_indexbuf_build_on_device(SIZE);
GPU_indexbuf_bind_as_ssbo(ibo, GPU_shader_get_ssbo(shader, "out_indices"));
GPU_indexbuf_bind_as_ssbo(ibo, GPU_shader_get_ssbo_binding(shader, "out_indices"));
/* Dispatch compute task. */
GPU_compute_dispatch(shader, SIZE, 1, 1);
@ -228,7 +228,7 @@ static void test_gpu_shader_compute_ssbo()
/* Construct IBO. */
GPUStorageBuf *ssbo = GPU_storagebuf_create_ex(
SIZE * sizeof(uint32_t), nullptr, GPU_USAGE_DEVICE_ONLY, __func__);
GPU_storagebuf_bind(ssbo, GPU_shader_get_ssbo(shader, "out_indices"));
GPU_storagebuf_bind(ssbo, GPU_shader_get_ssbo_binding(shader, "out_indices"));
/* Dispatch compute task. */
GPU_compute_dispatch(shader, SIZE, 1, 1);
@ -264,8 +264,8 @@ static void test_gpu_shader_ssbo_binding()
EXPECT_NE(shader, nullptr);
GPU_shader_bind(shader);
EXPECT_EQ(0, GPU_shader_get_ssbo(shader, "data0"));
EXPECT_EQ(1, GPU_shader_get_ssbo(shader, "data1"));
EXPECT_EQ(0, GPU_shader_get_ssbo_binding(shader, "data0"));
EXPECT_EQ(1, GPU_shader_get_ssbo_binding(shader, "data1"));
/* Cleanup. */
GPU_shader_unbind();

View File

@ -94,7 +94,7 @@ class CompositeOperation : public NodeOperation {
image.bind_as_texture(shader, "input_tx");
GPUTexture *output_texture = context().get_output_texture();
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(output_texture, image_unit);
const int2 compositing_region_size = context().get_compositing_region_size();
@ -122,7 +122,7 @@ class CompositeOperation : public NodeOperation {
image.bind_as_texture(shader, "input_tx");
GPUTexture *output_texture = context().get_output_texture();
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(output_texture, image_unit);
const int2 compositing_region_size = context().get_compositing_region_size();
@ -152,7 +152,7 @@ class CompositeOperation : public NodeOperation {
alpha.bind_as_texture(shader, "alpha_tx");
GPUTexture *output_texture = context().get_output_texture();
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(output_texture, image_unit);
const int2 compositing_region_size = context().get_compositing_region_size();

View File

@ -122,7 +122,7 @@ class DilateErodeOperation : public NodeOperation {
const int2 transposed_domain = int2(domain.size.y, domain.size.x);
GPUTexture *horizontal_pass_result = texture_pool().acquire_color(transposed_domain);
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(horizontal_pass_result, image_unit);
compute_dispatch_threads_at_least(shader, domain.size);
@ -143,7 +143,7 @@ class DilateErodeOperation : public NodeOperation {
GPU_shader_uniform_1i(shader, "radius", math::abs(get_distance()));
GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH);
const int texture_image_unit = GPU_shader_get_texture_binding(shader, "input_tx");
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
GPU_texture_bind(horizontal_pass_result, texture_image_unit);
const Domain domain = compute_domain();
@ -273,7 +273,7 @@ class DilateErodeOperation : public NodeOperation {
const int2 transposed_domain = int2(domain.size.y, domain.size.x);
GPUTexture *horizontal_pass_result = texture_pool().acquire_color(transposed_domain);
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(horizontal_pass_result, image_unit);
compute_dispatch_threads_at_least(shader, domain.size);
@ -293,7 +293,7 @@ class DilateErodeOperation : public NodeOperation {
GPU_shader_bind(shader);
GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH);
const int texture_image_unit = GPU_shader_get_texture_binding(shader, "input_tx");
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
GPU_texture_bind(horizontal_pass_result, texture_image_unit);
const MorphologicalDistanceFeatherWeights &weights =

View File

@ -525,7 +525,7 @@ class ImageOperation : public NodeOperation {
GPUShader *shader = shader_manager().get(get_shader_name(identifier));
GPU_shader_bind(shader);
const int input_unit = GPU_shader_get_texture_binding(shader, "input_tx");
const int input_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
GPU_texture_bind(image_texture, input_unit);
result.bind_as_image(shader, "output_img");
@ -859,7 +859,7 @@ class RenderLayerOperation : public NodeOperation {
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
const int input_unit = GPU_shader_get_texture_binding(shader, "input_tx");
const int input_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
GPU_texture_bind(pass_texture, input_unit);
const int2 compositing_region_size = context().get_compositing_region_size();
@ -889,7 +889,7 @@ class RenderLayerOperation : public NodeOperation {
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
const int input_unit = GPU_shader_get_texture_binding(shader, "input_tx");
const int input_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
GPU_texture_bind(pass_texture, input_unit);
const int2 compositing_region_size = context().get_compositing_region_size();

View File

@ -128,7 +128,7 @@ class MovieClipOperation : public NodeOperation {
GPUShader *shader = shader_manager().get("compositor_convert_color_to_half_color");
GPU_shader_bind(shader);
const int input_unit = GPU_shader_get_texture_binding(shader, "input_tx");
const int input_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
GPU_texture_bind(movie_clip_texture, input_unit);
result.bind_as_image(shader, "output_img");
@ -162,7 +162,7 @@ class MovieClipOperation : public NodeOperation {
GPUShader *shader = shader_manager().get("compositor_extract_alpha_from_color");
GPU_shader_bind(shader);
const int input_unit = GPU_shader_get_texture_binding(shader, "input_tx");
const int input_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
GPU_texture_bind(movie_clip_texture, input_unit);
result.bind_as_image(shader, "output_img");

View File

@ -77,7 +77,7 @@ class ViewerOperation : public NodeOperation {
second_image.bind_as_texture(shader, "second_image_tx");
GPUTexture *output_texture = context().get_output_texture();
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(output_texture, image_unit);
compute_dispatch_threads_at_least(shader, compositing_region_size);

View File

@ -123,7 +123,7 @@ class ViewerOperation : public NodeOperation {
image.bind_as_texture(shader, "input_tx");
GPUTexture *output_texture = context().get_output_texture();
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(output_texture, image_unit);
const int2 compositing_region_size = context().get_compositing_region_size();
@ -151,7 +151,7 @@ class ViewerOperation : public NodeOperation {
image.bind_as_texture(shader, "input_tx");
GPUTexture *output_texture = context().get_output_texture();
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(output_texture, image_unit);
const int2 compositing_region_size = context().get_compositing_region_size();
@ -181,7 +181,7 @@ class ViewerOperation : public NodeOperation {
alpha.bind_as_texture(shader, "alpha_tx");
GPUTexture *output_texture = context().get_output_texture();
const int image_unit = GPU_shader_get_texture_binding(shader, "output_img");
const int image_unit = GPU_shader_get_sampler_binding(shader, "output_img");
GPU_texture_image_bind(output_texture, image_unit);
const int2 compositing_region_size = context().get_compositing_region_size();

View File

@ -533,7 +533,7 @@ static PyObject *pygpu_shader_uniform_sampler(BPyGPUShader *self, PyObject *args
}
GPU_shader_bind(self->shader);
int slot = GPU_shader_get_texture_binding(self->shader, name);
int slot = GPU_shader_get_sampler_binding(self->shader, name);
GPU_texture_bind(py_texture->tex, slot);
GPU_shader_uniform_1i(self->shader, name, slot);
@ -559,7 +559,7 @@ static PyObject *pygpu_shader_uniform_block(BPyGPUShader *self, PyObject *args)
return NULL;
}
int binding = GPU_shader_get_uniform_block_binding(self->shader, name);
int binding = GPU_shader_get_ubo_binding(self->shader, name);
if (binding == -1) {
PyErr_SetString(
PyExc_BufferError,

View File

@ -842,7 +842,7 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
int color_loc = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR);
int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
int rect_geo_loc = GPU_shader_get_uniform(shader, "rect_geom");
int texture_bind_loc = GPU_shader_get_texture_binding(shader, "image");
int texture_bind_loc = GPU_shader_get_sampler_binding(shader, "image");
GPU_texture_bind(texture, texture_bind_loc);