Cleanup: GPU: UniformAttribute: Improve const correctness

Removes a warning and tidy the API.
This commit is contained in:
Clément Foucault
2022-09-02 19:01:12 +02:00
parent 65ad36f5fd
commit da0bd86739
7 changed files with 15 additions and 13 deletions

View File

@@ -564,7 +564,8 @@ typedef struct DRWUniformAttrBuf {
struct DRWUniformAttrBuf *next_empty;
} DRWUniformAttrBuf;
static DRWUniformAttrBuf *drw_uniform_attrs_pool_ensure(GHash *table, GPUUniformAttrList *key)
static DRWUniformAttrBuf *drw_uniform_attrs_pool_ensure(GHash *table,
const GPUUniformAttrList *key)
{
void **pkey, **pval;
@@ -669,7 +670,7 @@ static void drw_uniform_attribute_lookup(GPUUniformAttr *attr,
}
void drw_uniform_attrs_pool_update(GHash *table,
GPUUniformAttrList *key,
const GPUUniformAttrList *key,
DRWResourceHandle *handle,
Object *ob,
Object *dupli_parent,
@@ -690,7 +691,8 @@ void drw_uniform_attrs_pool_update(GHash *table,
}
}
DRWSparseUniformBuf *DRW_uniform_attrs_pool_find_ubo(GHash *table, struct GPUUniformAttrList *key)
DRWSparseUniformBuf *DRW_uniform_attrs_pool_find_ubo(GHash *table,
const struct GPUUniformAttrList *key)
{
DRWUniformAttrBuf *buffer = BLI_ghash_lookup(table, key);
return buffer ? &buffer->ubos : NULL;

View File

@@ -106,4 +106,4 @@ struct GHash *DRW_uniform_attrs_pool_new(void);
void DRW_uniform_attrs_pool_flush_all(struct GHash *table);
void DRW_uniform_attrs_pool_clear_all(struct GHash *table);
struct DRWSparseUniformBuf *DRW_uniform_attrs_pool_find_ubo(struct GHash *table,
struct GPUUniformAttrList *key);
const struct GPUUniformAttrList *key);

View File

@@ -377,7 +377,7 @@ struct DRWUniform {
/* DRW_UNIFORM_INT_COPY */
int ivalue[4];
/* DRW_UNIFORM_BLOCK_OBATTRS */
struct GPUUniformAttrList *uniform_attrs;
const struct GPUUniformAttrList *uniform_attrs;
};
int location; /* Uniform location or binding point for textures and UBO's. */
uint8_t type; /* #DRWUniformType */
@@ -403,7 +403,7 @@ struct DRWShadingGroup {
DRWResourceHandle pass_handle; /* Memblock key to parent pass. */
/* Set of uniform attributes used by this shader. */
struct GPUUniformAttrList *uniform_attrs;
const struct GPUUniformAttrList *uniform_attrs;
};
/* This struct is used after cache populate if using the Z sorting.
* It will not conflict with the above struct. */
@@ -681,7 +681,7 @@ GPUBatch *drw_cache_procedural_triangles_get(void);
GPUBatch *drw_cache_procedural_triangle_strips_get(void);
void drw_uniform_attrs_pool_update(struct GHash *table,
struct GPUUniformAttrList *key,
const struct GPUUniformAttrList *key,
DRWResourceHandle *handle,
struct Object *ob,
struct Object *dupli_parent,

View File

@@ -1638,7 +1638,7 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial
DRW_shgroup_uniform_block(grp, GPU_UBO_BLOCK_NAME, ubo);
}
GPUUniformAttrList *uattrs = GPU_material_uniform_attributes(material);
const GPUUniformAttrList *uattrs = GPU_material_uniform_attributes(material);
if (uattrs != NULL) {
int loc = GPU_shader_get_uniform_block_binding(grp->shader, GPU_ATTRIBUTE_UBO_BLOCK_NAME);
drw_shgroup_uniform_create_ex(grp, loc, DRW_UNIFORM_BLOCK_OBATTRS, uattrs, 0, 0, 1);

View File

@@ -326,10 +326,10 @@ typedef struct GPUUniformAttrList {
unsigned int count, hash_code;
} GPUUniformAttrList;
GPUUniformAttrList *GPU_material_uniform_attributes(const GPUMaterial *material);
const GPUUniformAttrList *GPU_material_uniform_attributes(const GPUMaterial *material);
struct GHash *GPU_uniform_attr_list_hash_new(const char *info);
void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, GPUUniformAttrList *src);
void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, const GPUUniformAttrList *src);
void GPU_uniform_attr_list_free(GPUUniformAttrList *set);
/* A callback passed to GPU_material_from_callbacks to construct the material graph by adding and

View File

@@ -225,9 +225,9 @@ ListBase GPU_material_textures(GPUMaterial *material)
return material->graph.textures;
}
GPUUniformAttrList *GPU_material_uniform_attributes(const GPUMaterial *material)
const GPUUniformAttrList *GPU_material_uniform_attributes(const GPUMaterial *material)
{
GPUUniformAttrList *attrs = &material->graph.uniform_attrs;
const GPUUniformAttrList *attrs = &material->graph.uniform_attrs;
return attrs->count > 0 ? attrs : NULL;
}

View File

@@ -292,7 +292,7 @@ struct GHash *GPU_uniform_attr_list_hash_new(const char *info)
return BLI_ghash_new(uniform_attr_list_hash, uniform_attr_list_cmp, info);
}
void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, GPUUniformAttrList *src)
void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, const GPUUniformAttrList *src)
{
dest->count = src->count;
dest->hash_code = src->hash_code;