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:
authorCampbell Barton <ideasman42@gmail.com>2018-07-18 16:09:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-07-18 16:10:31 +0300
commit428743a9b06cc09b4eb4dd3e7794d45d13457fb8 (patch)
treec80387088d4a89de88627f43665c73d805049a65 /source/blender/gpu/intern/gpu_shader.c
parentf882df9e0f9de99c37558ce375ce681c148eac82 (diff)
Cleanup: style for GPU module
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader.c')
-rw-r--r--source/blender/gpu/intern/gpu_shader.c104
1 files changed, 58 insertions, 46 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index c5325b6ff21..1eae073d9c0 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -214,8 +214,9 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH])
}
}
-static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH],
- bool use_opensubdiv)
+static void gpu_shader_standard_defines(
+ char defines[MAX_DEFINE_LENGTH],
+ bool use_opensubdiv)
{
/* some useful defines to detect GPU type */
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
@@ -244,11 +245,12 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH],
* a global typedef which we don't have better place to define
* in yet.
*/
- strcat(defines, "struct VertexData {\n"
- " vec4 position;\n"
- " vec3 normal;\n"
- " vec2 uv;"
- "};\n");
+ strcat(defines,
+ "struct VertexData {\n"
+ " vec4 position;\n"
+ " vec3 normal;\n"
+ " vec2 uv;"
+ "};\n");
}
#else
UNUSED_VARS(use_opensubdiv);
@@ -257,21 +259,23 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH],
return;
}
-GPUShader *GPU_shader_create(const char *vertexcode,
- const char *fragcode,
- const char *geocode,
- const char *libcode,
- const char *defines)
+GPUShader *GPU_shader_create(
+ const char *vertexcode,
+ const char *fragcode,
+ const char *geocode,
+ const char *libcode,
+ const char *defines)
{
- return GPU_shader_create_ex(vertexcode,
- fragcode,
- geocode,
- libcode,
- defines,
- GPU_SHADER_FLAGS_NONE,
- GPU_SHADER_TFB_NONE,
- NULL,
- 0);
+ return GPU_shader_create_ex(
+ vertexcode,
+ fragcode,
+ geocode,
+ libcode,
+ defines,
+ GPU_SHADER_FLAGS_NONE,
+ GPU_SHADER_TFB_NONE,
+ NULL,
+ 0);
}
#define DEBUG_SHADER_NONE ""
@@ -321,15 +325,16 @@ static void gpu_dump_shaders(const char **code, const int num_shaders, const cha
printf("Shader file written to disk: %s\n", shader_path);
}
-GPUShader *GPU_shader_create_ex(const char *vertexcode,
- const char *fragcode,
- const char *geocode,
- const char *libcode,
- const char *defines,
- const int flags,
- const GPUShaderTFBType tf_type,
- const char **tf_names,
- const int tf_count)
+GPUShader *GPU_shader_create_ex(
+ const char *vertexcode,
+ const char *fragcode,
+ const char *geocode,
+ const char *libcode,
+ const char *defines,
+ const int flags,
+ const GPUShaderTFBType tf_type,
+ const char **tf_names,
+ const int tf_count)
{
#ifdef WITH_OPENSUBDIV
bool use_opensubdiv = (flags & GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV) != 0;
@@ -366,8 +371,9 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
return NULL;
}
- gpu_shader_standard_defines(standard_defines,
- use_opensubdiv);
+ gpu_shader_standard_defines(
+ standard_defines,
+ use_opensubdiv);
gpu_shader_standard_extensions(standard_extensions);
if (vertexcode) {
@@ -410,12 +416,13 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
#ifdef WITH_OPENSUBDIV
/* TODO(sergey): Move to fragment shader source code generation. */
if (use_opensubdiv) {
- source[num_source++] =
+ source[num_source++] = (
"#ifdef USE_OPENSUBDIV\n"
"in block {\n"
" VertexData v;\n"
"} inpt;\n"
- "#endif\n";
+ "#endif\n"
+ );
}
#endif
@@ -502,13 +509,15 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
/* TODO(sergey): Find a better place for this. */
if (use_opensubdiv) {
if (GLEW_VERSION_4_1) {
- glProgramUniform1i(shader->program,
- GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location,
- 30); /* GL_TEXTURE30 */
-
- glProgramUniform1i(shader->program,
- GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location,
- 31); /* GL_TEXTURE31 */
+ glProgramUniform1i(
+ shader->program,
+ GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location,
+ 30); /* GL_TEXTURE30 */
+
+ glProgramUniform1i(
+ shader->program,
+ GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location,
+ 31); /* GL_TEXTURE31 */
}
else {
glUseProgram(shader->program);
@@ -903,17 +912,20 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
if (shader == GPU_SHADER_EDGES_FRONT_BACK_PERSP && !GLEW_VERSION_3_2) {
/* TODO: remove after switch to core profile (maybe) */
- static const GPUShaderStages legacy_fancy_edges =
- { datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl,
- datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl };
+ static const GPUShaderStages legacy_fancy_edges = {
+ datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl,
+ datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl,
+ };
stages = &legacy_fancy_edges;
}
if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR && !GLEW_VERSION_3_2) {
/* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */
/* TODO: remove after switch to core profile (maybe) */
- static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl,
- datatoc_gpu_shader_2D_line_dashed_frag_glsl };
+ static const GPUShaderStages legacy_dashed_lines = {
+ datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl,
+ datatoc_gpu_shader_2D_line_dashed_frag_glsl,
+ };
stages = &legacy_dashed_lines;
}