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:
authorJason Fielder <jason_apple>2022-03-30 21:24:39 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-03-30 21:31:12 +0300
commit922d53a791d53b77e5ffcf65003555fae0a0e883 (patch)
tree7804945d62f0c6366678efdffd4dffe98e5988e8 /source/blender/gpu
parent84fde382e43cff6407bfa3587fec9bd570cf9123 (diff)
Metal: Adding alternative support for GPU_PRIM_TRI_FAN/LINE_LOOP For Metal backend.
- Metal uniform array compatibility in DRW module. - Guard OpenGL-specific workarounds and flushes behind GPU_type_matches_ex API guard. Add further render boundaries for render paths called outside of the main loop. Authored by Apple: Michael Parkin-White Ref: T96261 Reviewed By: fclem Differential Revision: https://developer.blender.org/D14438
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_primitive.h6
-rw-r--r--source/blender/gpu/intern/gpu_batch_presets.c6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl26
3 files changed, 8 insertions, 30 deletions
diff --git a/source/blender/gpu/GPU_primitive.h b/source/blender/gpu/GPU_primitive.h
index 66759cf22d7..4860b037bfb 100644
--- a/source/blender/gpu/GPU_primitive.h
+++ b/source/blender/gpu/GPU_primitive.h
@@ -20,10 +20,12 @@ typedef enum {
GPU_PRIM_LINES,
GPU_PRIM_TRIS,
GPU_PRIM_LINE_STRIP,
- GPU_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */
+ GPU_PRIM_LINE_LOOP, /* GL has this, Vulkan and Metal do not */
GPU_PRIM_TRI_STRIP,
- GPU_PRIM_TRI_FAN,
+ GPU_PRIM_TRI_FAN, /* Metal API does not support this. */
+ /* Metal API does not support ADJ primitive types but
+ * handled via the geometry-shader-alternative path. */
GPU_PRIM_LINES_ADJ,
GPU_PRIM_TRIS_ADJ,
GPU_PRIM_LINE_STRIP_ADJ,
diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c
index c1c884ed028..ab5e23a846c 100644
--- a/source/blender/gpu/intern/gpu_batch_presets.c
+++ b/source/blender/gpu/intern/gpu_batch_presets.c
@@ -19,6 +19,7 @@
#include "GPU_batch.h"
#include "GPU_batch_presets.h" /* own include */
#include "GPU_batch_utils.h"
+#include "GPU_context.h"
/* -------------------------------------------------------------------- */
/** \name Local Structures
@@ -320,11 +321,12 @@ GPUBatch *GPU_batch_preset_quad(void)
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(preset_2d_format());
GPU_vertbuf_data_alloc(vbo, 4);
- float pos_data[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}};
+ float pos_data[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}};
GPU_vertbuf_attr_fill(vbo, g_presets_2d.attr_id.pos, pos_data);
/* Don't fill the color. */
- g_presets_2d.batch.quad = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO);
+ g_presets_2d.batch.quad = GPU_batch_create_ex(
+ GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
gpu_batch_presets_register(g_presets_2d.batch.quad);
}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
index 903c602c5d6..11bb311740c 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
@@ -16,14 +16,6 @@ void main()
vec2 uv;
vec2 co;
-#ifdef GPU_METAL
-/* Metal API does not support Triangle fan primitive topology.
- * When this shader is called using Triangle-Strip, vertex ID's
- * are in a different order. */
-# define GPU_PRIM_TRI_STRIP
-#endif
-
-#ifdef GPU_PRIM_TRI_STRIP
if (gl_VertexID == 0) {
co = rect_geom.xw;
uv = rect_icon.xw;
@@ -40,24 +32,6 @@ void main()
co = rect_geom.zy;
uv = rect_icon.zy;
}
-#else
- if (gl_VertexID == 0) {
- co = rect_geom.xy;
- uv = rect_icon.xy;
- }
- else if (gl_VertexID == 1) {
- co = rect_geom.xw;
- uv = rect_icon.xw;
- }
- else if (gl_VertexID == 2) {
- co = rect_geom.zw;
- uv = rect_icon.zw;
- }
- else {
- co = rect_geom.zy;
- uv = rect_icon.zy;
- }
-#endif
gl_Position = ModelViewProjectionMatrix * vec4(co, 0.0f, 1.0f);
texCoord_interp = uv;