Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-09-08 04:34:47 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-08 05:15:50 +0300
commitd2e9de93b8d1d6cd45abce8164d0f92af8f636d0 (patch)
treeaee6755004778a92e294484b4dfcc38a87820a0f /source/blender/gpu/intern/gpu_shader.cc
parent33b25b6a9e86082a40a24b14bb0a6aad708dfb11 (diff)
GPU: Cleanup implementation casts
- Use the syntactic wrap/unwrap method to make code more readable. - Update comment about hidden struct behind opaque types. - Cleanup GPUDrawList type.
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader.cc')
-rw-r--r--source/blender/gpu/intern/gpu_shader.cc35
1 files changed, 15 insertions, 20 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index 38acc773c49..eb0f7935b63 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -52,11 +52,6 @@ extern "C" char datatoc_gpu_shader_colorspace_lib_glsl[];
using namespace blender;
using namespace blender::gpu;
-/** Opaque type hidding blender::gpu::Shader */
-struct GPUShader {
- char _pad[1];
-};
-
/* -------------------------------------------------------------------- */
/** \name Debug functions
* \{ */
@@ -333,12 +328,12 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
return NULL;
};
- return reinterpret_cast<GPUShader *>(shader);
+ return wrap(shader);
}
void GPU_shader_free(GPUShader *shader)
{
- delete reinterpret_cast<Shader *>(shader);
+ delete unwrap(shader);
}
/** \} */
@@ -460,7 +455,7 @@ struct GPUShader *GPU_shader_create_from_arrays_impl(
void GPU_shader_bind(GPUShader *gpu_shader)
{
- Shader *shader = reinterpret_cast<Shader *>(gpu_shader);
+ Shader *shader = unwrap(gpu_shader);
GPUContext *ctx = GPU_context_active_get();
@@ -481,7 +476,7 @@ void GPU_shader_unbind(void)
#ifndef NDEBUG
GPUContext *ctx = GPU_context_active_get();
if (ctx->shader) {
- reinterpret_cast<Shader *>(ctx->shader)->unbind();
+ ctx->shader->unbind();
}
ctx->shader = NULL;
#endif
@@ -497,12 +492,12 @@ void GPU_shader_unbind(void)
bool GPU_shader_transform_feedback_enable(GPUShader *shader, GPUVertBuf *vertbuf)
{
- return reinterpret_cast<Shader *>(shader)->transform_feedback_enable(vertbuf);
+ return unwrap(shader)->transform_feedback_enable(vertbuf);
}
void GPU_shader_transform_feedback_disable(GPUShader *shader)
{
- reinterpret_cast<Shader *>(shader)->transform_feedback_disable();
+ unwrap(shader)->transform_feedback_disable();
}
/** \} */
@@ -513,48 +508,48 @@ void GPU_shader_transform_feedback_disable(GPUShader *shader)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
{
- ShaderInterface *interface = reinterpret_cast<Shader *>(shader)->interface;
+ ShaderInterface *interface = unwrap(shader)->interface;
const ShaderInput *uniform = interface->uniform_get(name);
return uniform ? uniform->location : -1;
}
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
{
- ShaderInterface *interface = reinterpret_cast<Shader *>(shader)->interface;
+ ShaderInterface *interface = unwrap(shader)->interface;
return interface->uniform_builtin((GPUUniformBuiltin)builtin);
}
int GPU_shader_get_builtin_block(GPUShader *shader, int builtin)
{
- ShaderInterface *interface = reinterpret_cast<Shader *>(shader)->interface;
+ ShaderInterface *interface = unwrap(shader)->interface;
return interface->ubo_builtin((GPUUniformBlockBuiltin)builtin);
}
/* DEPRECATED. */
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)
{
- ShaderInterface *interface = reinterpret_cast<Shader *>(shader)->interface;
+ ShaderInterface *interface = unwrap(shader)->interface;
const ShaderInput *ubo = interface->ubo_get(name);
return ubo ? ubo->location : -1;
}
int GPU_shader_get_uniform_block_binding(GPUShader *shader, const char *name)
{
- ShaderInterface *interface = reinterpret_cast<Shader *>(shader)->interface;
+ 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)
{
- ShaderInterface *interface = reinterpret_cast<Shader *>(shader)->interface;
+ ShaderInterface *interface = unwrap(shader)->interface;
const ShaderInput *tex = interface->uniform_get(name);
return tex ? tex->binding : -1;
}
int GPU_shader_get_attribute(GPUShader *shader, const char *name)
{
- ShaderInterface *interface = reinterpret_cast<Shader *>(shader)->interface;
+ ShaderInterface *interface = unwrap(shader)->interface;
const ShaderInput *attr = interface->attr_get(name);
return attr ? attr->location : -1;
}
@@ -581,13 +576,13 @@ int GPU_shader_get_program(GPUShader *UNUSED(shader))
void GPU_shader_uniform_vector(
GPUShader *shader, int loc, int len, int arraysize, const float *value)
{
- reinterpret_cast<Shader *>(shader)->uniform_float(loc, len, arraysize, value);
+ unwrap(shader)->uniform_float(loc, len, arraysize, value);
}
void GPU_shader_uniform_vector_int(
GPUShader *shader, int loc, int len, int arraysize, const int *value)
{
- reinterpret_cast<Shader *>(shader)->uniform_int(loc, len, arraysize, value);
+ unwrap(shader)->uniform_int(loc, len, arraysize, value);
}
void GPU_shader_uniform_int(GPUShader *shader, int location, int value)