Compare commits
1 Commits
tmp-dynami
...
tmp-gpu-po
Author | SHA1 | Date | |
---|---|---|---|
7f5219caa4 |
@@ -42,6 +42,7 @@
|
||||
#include "GPU_immediate_util.h"
|
||||
#include "GPU_matrix.h"
|
||||
#include "GPU_select.h"
|
||||
#include "GPU_shader_shared.h"
|
||||
#include "GPU_state.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
@@ -114,11 +115,18 @@ static void dial_geom_draw(const float color[4],
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
|
||||
struct ClippingData clipping_data;
|
||||
GPUUniformBuf *ubo = NULL;
|
||||
|
||||
if (clip_plane) {
|
||||
immBindBuiltinProgram(filled ? GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR :
|
||||
GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR);
|
||||
immUniform4fv("ClipPlane", clip_plane);
|
||||
immUniformMatrix4fv("ModelMatrix", axis_modal_mat);
|
||||
copy_v4_v4(clipping_data.clip_plane, clip_plane);
|
||||
copy_m4_m4(clipping_data.ModelMatrix, axis_modal_mat);
|
||||
ubo = GPU_uniformbuf_create_ex(sizeof(struct ClippingData), &clipping_data, __func__);
|
||||
immBindUniformBuf("clipping_data", ubo);
|
||||
|
||||
GPU_uniformbuf_bind(ubo, GPU_shader_uniformbuf_block())
|
||||
}
|
||||
else {
|
||||
immBindBuiltinProgram(filled ? GPU_SHADER_3D_UNIFORM_COLOR :
|
||||
@@ -175,6 +183,11 @@ static void dial_geom_draw(const float color[4],
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
if (ubo != NULL) {
|
||||
GPU_uniformbuf_free(ubo);
|
||||
ubo = NULL;
|
||||
}
|
||||
|
||||
UNUSED_VARS(select);
|
||||
#endif
|
||||
}
|
||||
|
@@ -428,6 +428,7 @@ shaders/infos/gpu_shader_3D_flat_color_info.hh
|
||||
shaders/infos/gpu_shader_3D_uniform_color_info.hh
|
||||
shaders/infos/gpu_shader_3D_smooth_color_info.hh
|
||||
shaders/infos/gpu_shader_3D_depth_only_info.hh
|
||||
shaders/infos/gpu_shader_3D_polyline_info.hh
|
||||
shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh
|
||||
shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh
|
||||
shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh
|
||||
|
@@ -89,3 +89,9 @@ struct MultiRectCallData {
|
||||
float4 calls_data[MAX_CALLS * 3];
|
||||
};
|
||||
BLI_STATIC_ASSERT_ALIGN(struct MultiRectCallData, 16)
|
||||
|
||||
struct ClippingData {
|
||||
float4x4 ModelMatrix;
|
||||
float4 clip_plane;
|
||||
};
|
||||
BLI_STATIC_ASSERT_ALIGN(struct ClippingData, 16)
|
||||
|
@@ -236,39 +236,16 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = {
|
||||
.frag = datatoc_gpu_shader_uniform_color_frag_glsl,
|
||||
},
|
||||
|
||||
[GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR] =
|
||||
{
|
||||
.name = "GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR",
|
||||
.vert = datatoc_gpu_shader_3D_polyline_vert_glsl,
|
||||
.geom = datatoc_gpu_shader_3D_polyline_geom_glsl,
|
||||
.frag = datatoc_gpu_shader_3D_polyline_frag_glsl,
|
||||
.defs = "#define UNIFORM\n",
|
||||
},
|
||||
[GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR] = {.name = "GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR",
|
||||
.create_info =
|
||||
"gpu_shader_3D_polyline_uniform_color"},
|
||||
[GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR] =
|
||||
{
|
||||
.name = "GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR",
|
||||
.vert = datatoc_gpu_shader_3D_polyline_vert_glsl,
|
||||
.geom = datatoc_gpu_shader_3D_polyline_geom_glsl,
|
||||
.frag = datatoc_gpu_shader_3D_polyline_frag_glsl,
|
||||
.defs = "#define UNIFORM\n"
|
||||
"#define CLIP\n",
|
||||
},
|
||||
[GPU_SHADER_3D_POLYLINE_FLAT_COLOR] =
|
||||
{
|
||||
.name = "GPU_SHADER_3D_POLYLINE_FLAT_COLOR",
|
||||
.vert = datatoc_gpu_shader_3D_polyline_vert_glsl,
|
||||
.geom = datatoc_gpu_shader_3D_polyline_geom_glsl,
|
||||
.frag = datatoc_gpu_shader_3D_polyline_frag_glsl,
|
||||
.defs = "#define FLAT\n",
|
||||
},
|
||||
[GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR] =
|
||||
{
|
||||
.name = "GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR",
|
||||
.vert = datatoc_gpu_shader_3D_polyline_vert_glsl,
|
||||
.geom = datatoc_gpu_shader_3D_polyline_geom_glsl,
|
||||
.frag = datatoc_gpu_shader_3D_polyline_frag_glsl,
|
||||
.defs = "#define SMOOTH\n",
|
||||
},
|
||||
{.name = "GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR",
|
||||
.create_info = "gpu_shader_3D_polyline_clipped_uniform_color"},
|
||||
[GPU_SHADER_3D_POLYLINE_FLAT_COLOR] = {.name = "GPU_SHADER_3D_POLYLINE_FLAT_COLOR",
|
||||
.create_info = "gpu_shader_3D_polyline_flat_color"},
|
||||
[GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR] = {.name = "GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR",
|
||||
.create_info = "gpu_shader_3D_polyline_smooth_color"},
|
||||
|
||||
[GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] =
|
||||
{
|
||||
|
@@ -16,13 +16,13 @@ out vec4 fragColor;
|
||||
void main()
|
||||
{
|
||||
#ifdef CLIP
|
||||
if (clip < 0.0) {
|
||||
if (geom_out.clip < 0.0) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
fragColor = finalColor;
|
||||
fragColor = geom_out.finalColor;
|
||||
if (lineSmooth) {
|
||||
fragColor.a *= clamp((lineWidth + SMOOTH_WIDTH) * 0.5 - abs(smoothline), 0.0, 1.0);
|
||||
fragColor.a *= clamp((lineWidth + SMOOTH_WIDTH) * 0.5 - abs(geom_out.smoothline), 0.0, 1.0);
|
||||
}
|
||||
fragColor = blender_srgb_to_framebuffer_space(fragColor);
|
||||
}
|
||||
|
@@ -41,26 +41,26 @@ vec4 clip_line_point_homogeneous_space(vec4 p, vec4 q)
|
||||
void do_vertex(const int i, vec4 pos, vec2 ofs)
|
||||
{
|
||||
#if defined(UNIFORM)
|
||||
finalColor = color;
|
||||
geom_out.finalColor = color;
|
||||
|
||||
#elif defined(FLAT)
|
||||
/* WATCH: Assuming last provoking vertex. */
|
||||
finalColor = finalColor_g[1];
|
||||
geom_out.finalColor = geom_in[1].finalColor_g;
|
||||
|
||||
#elif defined(SMOOTH)
|
||||
finalColor = finalColor_g[i];
|
||||
geom_out.finalColor = geom_in[i].finalColor_g;
|
||||
#endif
|
||||
|
||||
#ifdef CLIP
|
||||
clip = clip_g[i];
|
||||
geom_out.clip = geom_in[i].clip_g;
|
||||
#endif
|
||||
|
||||
smoothline = (lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
geom_out.smoothline = (lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
gl_Position = pos;
|
||||
gl_Position.xy += ofs * pos.w;
|
||||
EmitVertex();
|
||||
|
||||
smoothline = -(lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
geom_out.smoothline = -(lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
gl_Position = pos;
|
||||
gl_Position.xy -= ofs * pos.w;
|
||||
EmitVertex();
|
||||
|
@@ -20,10 +20,10 @@ void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
#if !defined(UNIFORM)
|
||||
finalColor_g = color;
|
||||
geom_in.finalColor_g = color;
|
||||
#endif
|
||||
|
||||
#ifdef CLIP
|
||||
clip_g = dot(ModelMatrix * vec4(pos, 1.0), ClipPlane);
|
||||
geom_in.clip_g = dot(clipping_data.ModelMatrix * vec4(pos, 1.0), clipping_data.clip_plane);
|
||||
#endif
|
||||
}
|
||||
|
@@ -21,13 +21,71 @@
|
||||
* \ingroup gpu
|
||||
*/
|
||||
|
||||
|
||||
#include "gpu_interface_info.hh"
|
||||
#include "gpu_shader_create_info.hh"
|
||||
|
||||
/* TODO(jbakker): Skipped as it needs a uniform/storage buffer. */
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color)
|
||||
/* Interfaces between vertex stage and geometry stage. */
|
||||
GPU_SHADER_INTERFACE_INFO(polyline_color_iface, "geom_in").smooth(Type::VEC4, "finalColor_g");
|
||||
GPU_SHADER_INTERFACE_INFO(polyline_color_clipped_iface, "geom_in")
|
||||
.smooth(Type::VEC4, "finalColor_g")
|
||||
.smooth(Type::FLOAT, "clip_g");
|
||||
GPU_SHADER_INTERFACE_INFO(polyline_uniform_color_clipped_iface, "geom_in")
|
||||
.smooth(Type::FLOAT, "clip_g");
|
||||
|
||||
/* Interfaces between geometry stage and fragment stage. */
|
||||
GPU_SHADER_INTERFACE_INFO(polyline_clipped_iface, "geom_out")
|
||||
.smooth(Type::VEC4, "finalColor")
|
||||
.no_perspective(Type::FLOAT, "smoothline")
|
||||
.smooth(Type::FLOAT, "clip");
|
||||
GPU_SHADER_INTERFACE_INFO(polyline_unclipped_iface, "geom_out")
|
||||
.smooth(Type::VEC4, "finalColor")
|
||||
.no_perspective(Type::FLOAT, "smoothline");
|
||||
|
||||
/* Abstract create info for polyline shaders. */
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline)
|
||||
.vertex_in(0, Type::VEC3, "pos")
|
||||
.geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.push_constant(0, Type::MAT4, "ModelViewProjectionMatrix")
|
||||
/* Reserved space for Vec4 (16-19) to store uniform color. */
|
||||
.push_constant(20, Type::VEC2, "viewportSize")
|
||||
.push_constant(24, Type::FLOAT, "lineWidth")
|
||||
.push_constant(25, Type::BOOL, "lineSmooth")
|
||||
.typedef_source("GPU_shader_shared.h")
|
||||
.vertex_source("gpu_shader_3D_polyline_vert.glsl")
|
||||
.geometry_source("gpu_shader_3D_polyline_geom.glsl")
|
||||
.fragment_source("gpu_shader_3D_polyline_frag.glsl")
|
||||
.additional_info("gpu_srgb_to_framebuffer_space");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_flat_color)
|
||||
.vertex_in(1, Type::VEC4, "color")
|
||||
.vertex_out(polyline_color_iface)
|
||||
.geometry_out(polyline_unclipped_iface)
|
||||
.define("FLAT")
|
||||
.additional_info("gpu_shader_3D_polyline")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color)
|
||||
.geometry_out(polyline_unclipped_iface)
|
||||
.push_constant(16, Type::VEC4, "color")
|
||||
.define("UNIFORM")
|
||||
.additional_info("gpu_shader_3D_polyline")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_clipped_uniform_color)
|
||||
.vertex_out(polyline_uniform_color_clipped_iface)
|
||||
.geometry_out(polyline_clipped_iface)
|
||||
.uniform_buf(0, "ClippingData", "clipping_data")
|
||||
.push_constant(16, Type::VEC4, "color")
|
||||
.define("UNIFORM")
|
||||
.define("CLIP")
|
||||
.additional_info("gpu_shader_3D_polyline")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_smooth_color)
|
||||
.vertex_in(1, Type::VEC4, "color")
|
||||
.vertex_out(polyline_color_iface)
|
||||
.geometry_out(polyline_unclipped_iface)
|
||||
.define("SMOOTH")
|
||||
.additional_info("gpu_shader_3D_polyline")
|
||||
.do_static_compilation(true);
|
||||
|
Reference in New Issue
Block a user