diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-12 15:30:28 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-12 15:30:28 +0300 |
commit | 39fabaddfd770f7d92a5aabb0d0255d6fc97cd24 (patch) | |
tree | d44e6c37094e53287596f33ecf8423eec8e7c51b /source/blender | |
parent | 721c691a2750d9eb005343a9d2e25fdac6ff1493 (diff) |
GPU: Remove residue of OpenSubdiv
Was done more like a hack on top of old drawing pipeline.
Should be re-implemented to fit new draw manager closer.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/draw_manager_shader.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/gpu/GPU_shader.h | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 47 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 81 |
7 files changed, 3 insertions, 151 deletions
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index 0c44acb3f9c..31a74885e23 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -293,7 +293,7 @@ GPUShader *DRW_shader_create_with_transform_feedback( const char *vert, const char *geom, const char *defines, const GPUShaderTFBType prim_type, const char **varying_names, const int varying_count) { - return GPU_shader_create_ex(vert, NULL, geom, NULL, defines, GPU_SHADER_FLAGS_NONE, + return GPU_shader_create_ex(vert, NULL, geom, NULL, defines, prim_type, varying_names, varying_count, __func__); } diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 7760b89571c..20360cc62cb 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -255,8 +255,4 @@ if(WITH_IMAGE_DDS) add_definitions(-DWITH_DDS) endif() -if(WITH_OPENSUBDIV) - add_definitions(-DWITH_OPENSUBDIV) -endif() - blender_add_lib(bf_gpu "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 03e45e63132..c9a87a7e187 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -44,12 +44,6 @@ struct GPUUniformBuffer; * - only for fragment shaders now * - must call texture bind before setting a texture as uniform! */ -enum { - GPU_SHADER_FLAGS_NONE = 0, - GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV = (1 << 0), - GPU_SHADER_FLAGS_NEW_SHADING = (1 << 1), -}; - typedef enum GPUShaderTFBType { GPU_SHADER_TFB_NONE = 0, /* Transform feedback unsupported. */ GPU_SHADER_TFB_POINTS = 1, @@ -70,7 +64,6 @@ GPUShader *GPU_shader_create_ex( const char *geocode, const char *libcode, const char *defines, - const int flags, const GPUShaderTFBType tf_type, const char **tf_names, const int tf_count, diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 2b81ec02c9c..7c312f5f36b 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -636,21 +636,10 @@ static int codegen_process_uniforms_functions(GPUMaterial *material, DynStr *ds, BLI_dynstr_append(ds, ";\n"); } else if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { -#ifdef WITH_OPENSUBDIV - bool skip_opensubdiv = input->attribtype == CD_TANGENT; - if (skip_opensubdiv) { - BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n"); - } -#endif BLI_dynstr_appendf( ds, "%s %s var%d;\n", GLEW_VERSION_3_0 ? "in" : "varying", GPU_DATATYPE_STR[input->type], input->attribid); -#ifdef WITH_OPENSUBDIV - if (skip_opensubdiv) { - BLI_dynstr_appendf(ds, "#endif\n"); - } -#endif } } } @@ -774,12 +763,6 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO char *code; int builtins; -#ifdef WITH_OPENSUBDIV - GPUNode *node; - GPUInput *input; -#endif - - #if 0 BLI_dynstr_append(ds, FUNCTION_PROTOTYPES); #endif @@ -819,36 +802,6 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO if (builtins & GPU_VIEW_POSITION) BLI_dynstr_append(ds, "\tvec3 viewposition = viewPosition;\n"); - /* Calculate tangent space. */ -#ifdef WITH_OPENSUBDIV - { - bool has_tangent = false; - for (node = nodes->first; node; node = node->next) { - for (input = node->inputs.first; input; input = input->next) { - if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { - if (input->attribtype == CD_TANGENT) { - BLI_dynstr_appendf( - ds, "#ifdef USE_OPENSUBDIV\n"); - BLI_dynstr_appendf( - ds, "\t%s var%d;\n", - GPU_DATATYPE_STR[input->type], - input->attribid); - if (has_tangent == false) { - BLI_dynstr_appendf(ds, "\tvec3 Q1 = dFdx(inpt.v.position.xyz);\n"); - BLI_dynstr_appendf(ds, "\tvec3 Q2 = dFdy(inpt.v.position.xyz);\n"); - BLI_dynstr_appendf(ds, "\tvec2 st1 = dFdx(inpt.v.uv);\n"); - BLI_dynstr_appendf(ds, "\tvec2 st2 = dFdy(inpt.v.uv);\n"); - BLI_dynstr_appendf(ds, "\tvec3 T = normalize(Q1 * st2.t - Q2 * st1.t);\n"); - } - BLI_dynstr_appendf(ds, "\tvar%d = vec4(T, 1.0);\n", input->attribid); - BLI_dynstr_appendf(ds, "#endif\n"); - } - } - } - } - } -#endif - codegen_declare_tmps(ds, nodes); codegen_call_functions(ds, nodes, output); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 92539fc2fb3..7b64161ddd2 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -85,13 +85,6 @@ # include "smoke_API.h" #endif -#ifdef WITH_OPENSUBDIV -# include "BKE_subsurf.h" -# include "BKE_editmesh.h" - -# include "gpu_codegen.h" -#endif - extern Material defmaterial; /* from material.c */ //* Checking powers of two for images since OpenGL ES requires it */ diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 3f5d3282f0c..0d37dff3f9e 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -58,10 +58,6 @@ #include "gpu_codegen.h" -#ifdef WITH_OPENSUBDIV -# include "BKE_DerivedMesh.h" -#endif - /* Structs */ #define MAX_COLOR_BAND 128 @@ -108,8 +104,6 @@ struct GPUMaterial { int objectinfoloc; - bool is_opensubdiv; - /* XXX: Should be in Material. But it depends on the output node * used and since the output selection is difference for GPUMaterial... */ diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 803a6319017..55ba862548e 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -246,9 +246,7 @@ 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]) { /* some useful defines to detect GPU type */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) @@ -258,28 +256,6 @@ static void gpu_shader_standard_defines( else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) strcat(defines, "#define GPU_INTEL\n"); -#ifdef WITH_OPENSUBDIV - /* TODO(sergey): Check whether we actually compiling shader for - * the OpenSubdiv mesh. - */ - if (use_opensubdiv) { - strcat(defines, "#define USE_OPENSUBDIV\n"); - - /* TODO(sergey): not strictly speaking a define, but this is - * 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"); - } -#else - UNUSED_VARS(use_opensubdiv); -#endif - return; } @@ -297,7 +273,6 @@ GPUShader *GPU_shader_create( geocode, libcode, defines, - GPU_SHADER_FLAGS_NONE, GPU_SHADER_TFB_NONE, NULL, 0, @@ -357,18 +332,11 @@ GPUShader *GPU_shader_create_ex( const char *geocode, const char *libcode, const char *defines, - const int flags, const GPUShaderTFBType tf_type, const char **tf_names, const int tf_count, const char *shname) { -#ifdef WITH_OPENSUBDIV - bool use_opensubdiv = (flags & GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV) != 0; -#else - UNUSED_VARS(flags); - bool use_opensubdiv = false; -#endif GLint status; GLchar log[5000]; GLsizei length = 0; @@ -404,9 +372,7 @@ GPUShader *GPU_shader_create_ex( return NULL; } - gpu_shader_standard_defines( - standard_defines, - use_opensubdiv); + gpu_shader_standard_defines(standard_defines); gpu_shader_standard_extensions(standard_extensions); if (vertexcode) { @@ -446,19 +412,6 @@ GPUShader *GPU_shader_create_ex( source[num_source++] = standard_extensions; source[num_source++] = standard_defines; -#ifdef WITH_OPENSUBDIV - /* TODO(sergey): Move to fragment shader source code generation. */ - if (use_opensubdiv) { - source[num_source++] = ( - "#ifdef USE_OPENSUBDIV\n" - "in block {\n" - " VertexData v;\n" - "} inpt;\n" - "#endif\n" - ); - } -#endif - if (defines) source[num_source++] = defines; if (libcode) source[num_source++] = libcode; source[num_source++] = fragcode; @@ -508,13 +461,6 @@ GPUShader *GPU_shader_create_ex( } } -#ifdef WITH_OPENSUBDIV - if (use_opensubdiv) { - glBindAttribLocation(shader->program, 0, "position"); - glBindAttribLocation(shader->program, 1, "normal"); - } -#endif - if (tf_names != NULL) { glTransformFeedbackVaryings(shader->program, tf_count, tf_names, GL_INTERLEAVED_ATTRIBS); /* Primitive type must be setup */ @@ -538,29 +484,6 @@ GPUShader *GPU_shader_create_ex( shader->interface = GPU_shaderinterface_create(shader->program); -#ifdef WITH_OPENSUBDIV - /* 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 */ - } - else { - glUseProgram(shader->program); - glUniform1i(GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30); - glUniform1i(GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31); - glUseProgram(0); - } - } -#endif - return shader; } |