Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/opengl/gl_shader.cc
| Show All 19 Lines | |||||
| /** \file | /** \file | ||||
| * \ingroup gpu | * \ingroup gpu | ||||
| */ | */ | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "GPU_extensions.h" | |||||
| #include "GPU_platform.h" | #include "GPU_platform.h" | ||||
| #include "gl_backend.hh" | |||||
| #include "gl_vertex_buffer.hh" | |||||
| #include "gl_shader.hh" | #include "gl_shader.hh" | ||||
| #include "gl_shader_interface.hh" | #include "gl_shader_interface.hh" | ||||
| using namespace blender; | using namespace blender; | ||||
| using namespace blender::gpu; | using namespace blender::gpu; | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Creation / Destruction | /** \name Creation / Destruction | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | if (!GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY) || GLEW_VERSION_4_0) { | ||||
| STR_CONCAT(patch, slen, "#define GPU_ARB_texture_gather\n"); | STR_CONCAT(patch, slen, "#define GPU_ARB_texture_gather\n"); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (GLEW_ARB_shader_draw_parameters) { | if (GLEW_ARB_shader_draw_parameters) { | ||||
| STR_CONCAT(patch, slen, "#extension GL_ARB_shader_draw_parameters : enable\n"); | STR_CONCAT(patch, slen, "#extension GL_ARB_shader_draw_parameters : enable\n"); | ||||
| STR_CONCAT(patch, slen, "#define GPU_ARB_shader_draw_parameters\n"); | STR_CONCAT(patch, slen, "#define GPU_ARB_shader_draw_parameters\n"); | ||||
| } | } | ||||
| if (GPU_arb_texture_cube_map_array_is_supported()) { | if (GLContext::texture_cube_map_array_support) { | ||||
| STR_CONCAT(patch, slen, "#extension GL_ARB_texture_cube_map_array : enable\n"); | STR_CONCAT(patch, slen, "#extension GL_ARB_texture_cube_map_array : enable\n"); | ||||
| STR_CONCAT(patch, slen, "#define GPU_ARB_texture_cube_map_array\n"); | STR_CONCAT(patch, slen, "#define GPU_ARB_texture_cube_map_array\n"); | ||||
| } | } | ||||
| /* Derivative sign can change depending on implementation. */ | /* Derivative sign can change depending on implementation. */ | ||||
| float derivatives[2]; | STR_CONCATF(patch, slen, "#define DFDX_SIGN %1.1f\n", GLContext::derivative_signs[0]); | ||||
| GPU_get_dfdy_factors(derivatives); | STR_CONCATF(patch, slen, "#define DFDY_SIGN %1.1f\n", GLContext::derivative_signs[1]); | ||||
| STR_CONCATF(patch, slen, "#define DFDX_SIGN %1.1f\n", derivatives[0]); | |||||
| STR_CONCATF(patch, slen, "#define DFDY_SIGN %1.1f\n", derivatives[1]); | |||||
| BLI_assert(slen < sizeof(patch)); | BLI_assert(slen < sizeof(patch)); | ||||
| return patch; | return patch; | ||||
| } | } | ||||
| /* Create, compile and attach the shader stage to the shader program. */ | /* Create, compile and attach the shader stage to the shader program. */ | ||||
| GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *> sources) | GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *> sources) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
| void GLShader::transform_feedback_names_set(Span<const char *> name_list, | void GLShader::transform_feedback_names_set(Span<const char *> name_list, | ||||
| const eGPUShaderTFBType geom_type) | const eGPUShaderTFBType geom_type) | ||||
| { | { | ||||
| glTransformFeedbackVaryings( | glTransformFeedbackVaryings( | ||||
| shader_program_, name_list.size(), name_list.data(), GL_INTERLEAVED_ATTRIBS); | shader_program_, name_list.size(), name_list.data(), GL_INTERLEAVED_ATTRIBS); | ||||
| transform_feedback_type_ = geom_type; | transform_feedback_type_ = geom_type; | ||||
| } | } | ||||
| bool GLShader::transform_feedback_enable(GPUVertBuf *buf) | bool GLShader::transform_feedback_enable(GPUVertBuf *buf_) | ||||
| { | { | ||||
| if (transform_feedback_type_ == GPU_SHADER_TFB_NONE) { | if (transform_feedback_type_ == GPU_SHADER_TFB_NONE) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| BLI_assert(buf->vbo_id != 0); | GLVertBuf *buf = static_cast<GLVertBuf *>(unwrap(buf_)); | ||||
| BLI_assert(buf->vbo_id_ != 0); | |||||
| glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf->vbo_id); | glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf->vbo_id_); | ||||
| switch (transform_feedback_type_) { | switch (transform_feedback_type_) { | ||||
| case GPU_SHADER_TFB_POINTS: | case GPU_SHADER_TFB_POINTS: | ||||
| glBeginTransformFeedback(GL_POINTS); | glBeginTransformFeedback(GL_POINTS); | ||||
| break; | break; | ||||
| case GPU_SHADER_TFB_LINES: | case GPU_SHADER_TFB_LINES: | ||||
| glBeginTransformFeedback(GL_LINES); | glBeginTransformFeedback(GL_LINES); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines | |||||