WIP: uv-simple-select #1

Closed
Chris Blackbourn wants to merge 182 commits from uv-simple-select into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
6 changed files with 12 additions and 26 deletions
Showing only changes of commit 0f23bb8437 - Show all commits

View File

@ -105,7 +105,8 @@ GPUShader *BlenderFallbackDisplayShader::bind(int width, int height)
/* Bind shader now to enable uniform assignment. */ /* Bind shader now to enable uniform assignment. */
GPU_shader_bind(shader_program_); GPU_shader_bind(shader_program_);
GPU_shader_uniform_int(shader_program_, image_texture_location_, 0); float slot = 0;
GPU_shader_uniform_vector_int(shader_program_, image_texture_location_, 1, 1, &slot);
float size[2]; float size[2];
size[0] = width; size[0] = width;
size[1] = height; size[1] = height;

View File

@ -687,10 +687,12 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
state->vlattrs_loc = uni->location; state->vlattrs_loc = uni->location;
GPU_uniformbuf_bind(drw_ensure_layer_attribute_buffer(), uni->location); GPU_uniformbuf_bind(drw_ensure_layer_attribute_buffer(), uni->location);
break; break;
case DRW_UNIFORM_RESOURCE_CHUNK: case DRW_UNIFORM_RESOURCE_CHUNK: {
state->chunkid_loc = uni->location; state->chunkid_loc = uni->location;
GPU_shader_uniform_int(shgroup->shader, uni->location, 0); int zero = 0;
GPU_shader_uniform_vector_int(shgroup->shader, uni->location, 1, 1, &zero);
break; break;
}
case DRW_UNIFORM_RESOURCE_ID: case DRW_UNIFORM_RESOURCE_ID:
state->resourceid_loc = uni->location; state->resourceid_loc = uni->location;
break; break;
@ -807,7 +809,7 @@ static void draw_call_resource_bind(DRWCommandsState *state, const DRWResourceHa
int chunk = DRW_handle_chunk_get(handle); int chunk = DRW_handle_chunk_get(handle);
if (state->resource_chunk != chunk) { if (state->resource_chunk != chunk) {
if (state->chunkid_loc != -1) { if (state->chunkid_loc != -1) {
GPU_shader_uniform_int(DST.shader, state->chunkid_loc, chunk); GPU_shader_uniform_vector_int(DST.shader, state->chunkid_loc, 1, 1, &chunk);
} }
if (state->obmats_loc != -1) { if (state->obmats_loc != -1) {
GPU_uniformbuf_unbind(DST.vmempool->matrices_ubo[state->resource_chunk]); GPU_uniformbuf_unbind(DST.vmempool->matrices_ubo[state->resource_chunk]);
@ -827,7 +829,7 @@ static void draw_call_resource_bind(DRWCommandsState *state, const DRWResourceHa
if (state->resourceid_loc != -1) { if (state->resourceid_loc != -1) {
int id = DRW_handle_id_get(handle); int id = DRW_handle_id_get(handle);
if (state->resource_id != id) { if (state->resource_id != id) {
GPU_shader_uniform_int(DST.shader, state->resourceid_loc, id); GPU_shader_uniform_vector_int(DST.shader, state->resourceid_loc, 1, 1, &id);
state->resource_id = id; state->resource_id = id;
} }
} }

View File

@ -34,7 +34,7 @@ typedef struct IMMDrawPixelsTexState {
* To be used before calling #immDrawPixelsTex * To be used before calling #immDrawPixelsTex
* Default shader is #GPU_SHADER_2D_IMAGE_COLOR * Default shader is #GPU_SHADER_2D_IMAGE_COLOR
* You can still set uniforms with: * You can still set uniforms with:
* `GPU_shader_uniform_int(shader, GPU_shader_get_uniform(shader, "name"), 0);` * `GPU_shader_uniform_*(shader, "name", value);`
*/ */
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin); IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin);

View File

@ -273,10 +273,6 @@ int GPU_shader_get_builtin_block(GPUShader *shader, int builtin);
/** DEPRECATED: Kept only because of Python GPU API. */ /** DEPRECATED: Kept only because of Python GPU API. */
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name); int GPU_shader_get_uniform_block(GPUShader *shader, const char *name);
/** DEPRECATED: To be replaced by GPU_shader_uniform_vector. */
void GPU_shader_uniform_float(GPUShader *shader, int location, float value);
void GPU_shader_uniform_int(GPUShader *shader, int location, int value);
/** \} */ /** \} */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -630,20 +630,10 @@ void GPU_shader_uniform_vector_int(
unwrap(shader)->uniform_int(loc, len, array_size, value); unwrap(shader)->uniform_int(loc, len, array_size, value);
} }
void GPU_shader_uniform_int(GPUShader *shader, int location, int value)
{
GPU_shader_uniform_vector_int(shader, location, 1, 1, &value);
}
void GPU_shader_uniform_float(GPUShader *shader, int location, float value)
{
GPU_shader_uniform_vector(shader, location, 1, 1, &value);
}
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value) void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)
{ {
const int loc = GPU_shader_get_uniform(sh, name); const int loc = GPU_shader_get_uniform(sh, name);
GPU_shader_uniform_int(sh, loc, value); GPU_shader_uniform_vector_int(sh, loc, 1, 1, &value);
} }
void GPU_shader_uniform_1b(GPUShader *sh, const char *name, bool value) void GPU_shader_uniform_1b(GPUShader *sh, const char *name, bool value)
@ -672,7 +662,7 @@ void GPU_shader_uniform_4f(GPUShader *sh, const char *name, float x, float y, fl
void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value) void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value)
{ {
const int loc = GPU_shader_get_uniform(sh, name); const int loc = GPU_shader_get_uniform(sh, name);
GPU_shader_uniform_float(sh, loc, value); GPU_shader_uniform_vector(sh, loc, 1, 1, &value);
} }
void GPU_shader_uniform_2fv(GPUShader *sh, const char *name, const float data[2]) void GPU_shader_uniform_2fv(GPUShader *sh, const char *name, const float data[2])

View File

@ -120,10 +120,7 @@ static void engine_bind_display_space_shader(RenderEngine *UNUSED(engine), Scene
{ {
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE); GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE);
GPU_shader_bind(shader); GPU_shader_bind(shader);
/** \note "image" binding slot is 0. */
int img_loc = GPU_shader_get_uniform(shader, "image");
GPU_shader_uniform_int(shader, img_loc, 0);
} }
static void engine_unbind_display_space_shader(RenderEngine *UNUSED(engine)) static void engine_unbind_display_space_shader(RenderEngine *UNUSED(engine))