[Bf-blender-cvs] [5437af2e6fb] temp-gpu-uniform-builtin-structs: Rename GPUUniformBuiltinStructType to GPUShaderBlockType.
Jeroen Bakker
noreply at git.blender.org
Fri Jul 9 12:23:19 CEST 2021
Commit: 5437af2e6fbefa3ddcf284e89a710aaed5111e48
Author: Jeroen Bakker
Date: Fri Jul 9 09:24:06 2021 +0200
Branches: temp-gpu-uniform-builtin-structs
https://developer.blender.org/rB5437af2e6fbefa3ddcf284e89a710aaed5111e48
Rename GPUUniformBuiltinStructType to GPUShaderBlockType.
===================================================================
M source/blender/draw/intern/draw_manager_shader.c
M source/blender/gpu/GPU_shader.h
M source/blender/gpu/GPU_uniform_buffer_types.h
M source/blender/gpu/intern/gpu_shader.cc
M source/blender/gpu/intern/gpu_shader_private.hh
M source/blender/gpu/intern/gpu_uniform_buffer_private.hh
M source/blender/gpu/intern/gpu_uniform_buffer_structs.cc
M source/blender/gpu/tests/gpu_uniform_buffer_struct_test.cc
===================================================================
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 4d7d32164bc..d8c436f1ded 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -401,7 +401,7 @@ GPUShader *DRW_shader_create_with_transform_feedback(const char *vert,
prim_type,
varying_names,
varying_count,
- GPU_UNIFORM_STRUCT_NONE,
+ GPU_SHADER_BLOCK_CUSTOM,
__func__);
}
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index d0b3bb5e9e6..b1fefcdeb36 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -66,7 +66,7 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
const eGPUShaderTFBType tf_type,
const char **tf_names,
const int tf_count,
- const GPUUniformBuiltinStructType uniform_struct_type,
+ const GPUShaderBlockType uniform_struct_type,
const char *shname);
struct GPU_ShaderCreateFromArray_Params {
diff --git a/source/blender/gpu/GPU_uniform_buffer_types.h b/source/blender/gpu/GPU_uniform_buffer_types.h
index 36ce53d21c7..fb372582311 100644
--- a/source/blender/gpu/GPU_uniform_buffer_types.h
+++ b/source/blender/gpu/GPU_uniform_buffer_types.h
@@ -27,19 +27,19 @@
extern "C" {
#endif
-typedef enum GPUUniformBuiltinStructType {
- GPU_UNIFORM_STRUCT_NONE = 0,
- GPU_UNIFORM_STRUCT_1,
- GPU_NUM_UNIFORM_STRUCTS, /* Special value, denotes number of structs. */
-} GPUUniformBuiltinStructType;
+typedef enum GPUShaderBlockType {
+ GPU_SHADER_BLOCK_CUSTOM = 0,
+ GPU_SHADER_BLOCK_3D_COLOR,
+ GPU_NUM_SHADER_BLOCK_TYPES, /* Special value, denotes number of structs. */
+} GPUShaderBlockType;
-typedef struct GPUUniformBuiltinStruct1 {
+typedef struct GPUShaderBlock3dColor {
float ModelMatrix[4][4];
float ModelViewProjectionMatrix[4][4];
float color[4];
float WorldClipPlanes[6][4];
int SrgbTransform;
-} GPUUniformBuiltinStruct1;
+} GPUShaderBlock3dColor;
#ifdef __cplusplus
}
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index 048f4582f43..c3a100b17c6 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -102,7 +102,7 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
const eGPUShaderTFBType tf_type,
const char **tf_names,
const int tf_count,
- const GPUUniformBuiltinStructType uniform_struct_type,
+ const GPUShaderBlockType uniform_struct_type,
const char *shname)
{
/* At least a vertex shader and a fragment shader are required, or only a compute shader. */
@@ -111,7 +111,7 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
(computecode != nullptr)));
Shader *shader = GPUBackend::get()->shader_alloc(shname);
- if (uniform_struct_type != GPU_UNIFORM_STRUCT_NONE) {
+ if (uniform_struct_type != GPU_SHADER_BLOCK_CUSTOM) {
shader->set_shader_struct(uniform_struct_type);
}
@@ -188,10 +188,10 @@ GPUShader *GPU_shader_create_ex(const char *vertcode,
};
if (G.debug & G_DEBUG_GPU) {
- std::optional<GPUUniformBuiltinStructType> best_struct_type =
- find_smallest_uniform_builtin_struct(*shader->interface);
+ std::optional<GPUShaderBlockType> best_struct_type = find_smallest_uniform_builtin_struct(
+ *shader->interface);
if (best_struct_type) {
- if (/*uniform_struct_type != GPU_UNIFORM_STRUCT_NONE &&*/
+ if (/*uniform_struct_type != GPU_SHADER_BLOCK_CUSTOM &&*/
uniform_struct_type != *best_struct_type) {
CLOG_WARN(&LOG,
"Found better matching uniform struct for '%s'; current %d, suggested %d",
@@ -232,7 +232,7 @@ GPUShader *GPU_shader_create(const char *vertcode,
GPU_SHADER_TFB_NONE,
nullptr,
0,
- GPU_UNIFORM_STRUCT_NONE,
+ GPU_SHADER_BLOCK_CUSTOM,
shname);
}
@@ -250,7 +250,7 @@ GPUShader *GPU_shader_create_compute(const char *computecode,
GPU_SHADER_TFB_NONE,
nullptr,
0,
- GPU_UNIFORM_STRUCT_NONE,
+ GPU_SHADER_BLOCK_CUSTOM,
shname);
}
@@ -278,7 +278,7 @@ GPUShader *GPU_shader_create_from_python(const char *vertcode,
GPU_SHADER_TFB_NONE,
nullptr,
0,
- GPU_UNIFORM_STRUCT_NONE,
+ GPU_SHADER_BLOCK_CUSTOM,
"pyGPUShader");
MEM_SAFE_FREE(libcodecat);
diff --git a/source/blender/gpu/intern/gpu_shader_private.hh b/source/blender/gpu/intern/gpu_shader_private.hh
index 76f053674b7..4d9f39f758e 100644
--- a/source/blender/gpu/intern/gpu_shader_private.hh
+++ b/source/blender/gpu/intern/gpu_shader_private.hh
@@ -83,7 +83,7 @@ class Shader {
};
UniformBuiltinStruct *m_shader_struct = nullptr;
- void set_shader_struct(GPUUniformBuiltinStructType struct_type)
+ void set_shader_struct(GPUShaderBlockType struct_type)
{
m_shader_struct = new UniformBuiltinStruct(struct_type);
}
diff --git a/source/blender/gpu/intern/gpu_uniform_buffer_private.hh b/source/blender/gpu/intern/gpu_uniform_buffer_private.hh
index adeede8f03a..e2f1f29eb5d 100644
--- a/source/blender/gpu/intern/gpu_uniform_buffer_private.hh
+++ b/source/blender/gpu/intern/gpu_uniform_buffer_private.hh
@@ -90,12 +90,12 @@ static inline const UniformBuf *unwrap(const GPUUniformBuf *vert)
class UniformBuiltinStructType {
public:
- constexpr UniformBuiltinStructType(const GPUUniformBuiltinStructType type);
- static const UniformBuiltinStructType &get(const GPUUniformBuiltinStructType type);
+ constexpr UniformBuiltinStructType(const GPUShaderBlockType type);
+ static const UniformBuiltinStructType &get(const GPUShaderBlockType type);
bool has_all_builtin_uniforms(const ShaderInterface &interface) const;
- GPUUniformBuiltinStructType type;
+ GPUShaderBlockType type;
struct AttributeBinding {
int binding = -1;
size_t offset = 0;
@@ -124,7 +124,7 @@ class UniformBuiltinStruct {
bool is_dirty : 1;
};
- UniformBuiltinStruct(const GPUUniformBuiltinStructType type);
+ UniformBuiltinStruct(const GPUShaderBlockType type);
UniformBuiltinStruct(const UniformBuiltinStruct &other) = default;
UniformBuiltinStruct(UniformBuiltinStruct &&other) = default;
@@ -149,7 +149,7 @@ class UniformBuiltinStruct {
void *m_data;
};
-std::optional<const GPUUniformBuiltinStructType> find_smallest_uniform_builtin_struct(
+std::optional<const GPUShaderBlockType> find_smallest_uniform_builtin_struct(
const ShaderInterface &interface);
#undef DEBUG_NAME_LEN
diff --git a/source/blender/gpu/intern/gpu_uniform_buffer_structs.cc b/source/blender/gpu/intern/gpu_uniform_buffer_structs.cc
index b48cc8469eb..0f14a4ae8b0 100644
--- a/source/blender/gpu/intern/gpu_uniform_buffer_structs.cc
+++ b/source/blender/gpu/intern/gpu_uniform_buffer_structs.cc
@@ -63,23 +63,23 @@ static constexpr UniformBuiltinStructType::AttributeBinding determine_binding_st
switch (builtin_uniform) {
case GPU_UNIFORM_MODEL:
result.binding = to_binding_location(builtin_uniform);
- result.offset = offsetof(GPUUniformBuiltinStruct1, ModelMatrix);
+ result.offset = offsetof(GPUShaderBlock3dColor, ModelMatrix);
break;
case GPU_UNIFORM_MVP:
result.binding = to_binding_location(builtin_uniform);
- result.offset = offsetof(GPUUniformBuiltinStruct1, ModelViewProjectionMatrix);
+ result.offset = offsetof(GPUShaderBlock3dColor, ModelViewProjectionMatrix);
break;
case GPU_UNIFORM_COLOR:
result.binding = to_binding_location(builtin_uniform);
- result.offset = offsetof(GPUUniformBuiltinStruct1, color);
+ result.offset = offsetof(GPUShaderBlock3dColor, color);
break;
case GPU_UNIFORM_CLIPPLANES:
result.binding = to_binding_location(builtin_uniform);
- result.offset = offsetof(GPUUniformBuiltinStruct1, WorldClipPlanes);
+ result.offset = offsetof(GPUShaderBlock3dColor, WorldClipPlanes);
break;
case GPU_UNIFORM_SRGB_TRANSFORM:
result.binding = to_binding_location(builtin_uniform);
- result.offset = offsetof(GPUUniformBuiltinStruct1, SrgbTransform);
+ result.offset = offsetof(GPUShaderBlock3dColor, SrgbTransform);
break;
default:
@@ -90,22 +90,22 @@ static constexpr UniformBuiltinStructType::AttributeBinding determine_binding_st
}
static constexpr UniformBuiltinStructType::AttributeBinding determine_binding(
- const GPUUniformBuiltinStructType struct_type, const GPUUniformBuiltin builtin_uniform)
+ const GPUShaderBlockType struct_type, const GPUUniformBuiltin builtin_uniform)
{
switch (struct_type) {
- case GPU_UNIFORM_STRUCT_NONE:
- case GPU_NUM_UNIFORM_STRUCTS:
+ case GPU_SHADER_BLOCK_CUSTOM:
+ case GPU_NUM_SHADER_BLOCK_TYPES:
return {};
- case GPU_UNIFORM_STRUCT_1:
+ case GPU_SHADER_BLOCK_3D_COLOR:
return determine_binding_struct_1(builtin_uniform);
};
return {};
}
static constexpr std::array<const UniformBuiltinStructType::AttributeBinding, GPU_NUM_UNIFORMS>
-builtin_uniforms_for_struct_type(const GPUUniformBuiltinStructType struct_type)
+builtin_uniforms_for_struct_type(const GPUShaderBlockType struct_type)
{
return {
determine_binding(s
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list