diff options
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_framebuffer.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/GPU_shader_interface.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/GPU_texture.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/GPU_vertex_format.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.c | 15 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_interface.c | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_format.c | 41 |
7 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h index 7d0f8b0bcbf..213cbe30794 100644 --- a/source/blender/gpu/GPU_framebuffer.h +++ b/source/blender/gpu/GPU_framebuffer.h @@ -173,6 +173,8 @@ void GPU_framebuffer_clear(GPUFrameBuffer *fb, #define GPU_framebuffer_clear_color_depth_stencil(fb, col, depth, stencil) \ GPU_framebuffer_clear(fb, GPU_COLOR_BIT | GPU_DEPTH_BIT | GPU_STENCIL_BIT, col, depth, stencil) +void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float (*clear_cols)[4]); + void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, int x, int y, int w, int h, float *data); void GPU_framebuffer_read_color( GPUFrameBuffer *fb, int x, int y, int w, int h, int channels, int slot, float *data); diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index c636135d75b..8b0d25e51a3 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -55,6 +55,7 @@ typedef enum { GPU_UNIFORM_COLOR, /* vec4 color */ GPU_UNIFORM_BASE_INSTANCE, /* int baseInstance */ GPU_UNIFORM_RESOURCE_CHUNK, /* int resourceChunk */ + GPU_UNIFORM_RESOURCE_ID, /* int resourceId */ GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 338f4d906f6..50b7c23059d 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -95,6 +95,7 @@ typedef enum eGPUTextureFormat { #if 0 GPU_RGB10_A2, GPU_RGB10_A2UI, + GPU_SRGB8_A8, #endif GPU_R11F_G11F_B10F, GPU_DEPTH32F_STENCIL8, diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index cbc20f37f27..f5717645bc1 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -112,6 +112,8 @@ uint GPU_vertformat_attr_add( GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode); void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias); +void GPU_vertformat_multiload_enable(GPUVertFormat *format, int load_count); + void GPU_vertformat_deinterleave(GPUVertFormat *format); int GPU_vertformat_attr_id_get(const GPUVertFormat *, const char *name); diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index b0fbb0eae49..6197d5f99b8 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -614,6 +614,21 @@ void GPU_framebuffer_clear(GPUFrameBuffer *fb, glClear(mask); } +/* Clear all textures bound to this framebuffer with a different color. */ +void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float (*clear_cols)[4]) +{ + CHECK_FRAMEBUFFER_IS_BOUND(fb); + + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + GPUAttachmentType type = GPU_FB_COLOR_ATTACHMENT0; + for (int i = 0; type < GPU_FB_MAX_ATTACHEMENT; i++, type++) { + if (fb->attachments[type].tex != NULL) { + glClearBufferfv(GL_COLOR, i, clear_cols[i]); + } + } +} + void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, int x, int y, int w, int h, float *data) { CHECK_FRAMEBUFFER_IS_BOUND(fb); diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 983c5dfc27a..f895993a27d 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -67,6 +67,7 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u) [GPU_UNIFORM_COLOR] = "color", [GPU_UNIFORM_BASE_INSTANCE] = "baseInstance", [GPU_UNIFORM_RESOURCE_CHUNK] = "resourceChunk", + [GPU_UNIFORM_RESOURCE_ID] = "resourceId", [GPU_UNIFORM_CUSTOM] = NULL, [GPU_NUM_UNIFORMS] = NULL, diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index 65573b71c76..16d8f8f875b 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -206,6 +206,47 @@ void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias) attr->names[attr->name_len++] = copy_attr_name(format, alias); } +/** + * Makes vertex attrib from the next vertices to be accessible in the vertex shader. + * For an attrib named "attr" you can access the next nth vertex using "attrn". + * Use this function after specifying all the attribs in the format. + * + * NOTE: This does NOT work when using indexed rendering. + * NOTE: Only works for first attrib name. (this limitation can be changed if needed) + * + * WARNING: this function creates a lot of aliases/attribs, make sure to keep the attrib name + * short to avoid overflowing the namebuffer. + * */ +void GPU_vertformat_multiload_enable(GPUVertFormat *format, int load_count) +{ + /* Sanity check. Maximum can be upgraded if needed. */ + BLI_assert(load_count > 1 && load_count < 5); + /* We need a packed format because of format->stride. */ + if (!format->packed) { + VertexFormat_pack(format); + } + + BLI_assert((format->name_len + 1) * load_count < GPU_VERT_FORMAT_MAX_NAMES); + BLI_assert(format->attr_len * load_count <= GPU_VERT_ATTR_MAX_LEN); + BLI_assert(format->name_offset * load_count < GPU_VERT_ATTR_NAMES_BUF_LEN); + + const GPUVertAttr *attr = format->attrs; + int attr_len = format->attr_len; + for (int i = 0; i < attr_len; i++, attr++) { + const char *attr_name = GPU_vertformat_attr_name_get(format, attr, 0); + for (int j = 1; j < load_count; j++) { + char load_name[64]; + BLI_snprintf(load_name, sizeof(load_name), "%s%d", attr_name, j); + GPUVertAttr *dst_attr = &format->attrs[format->attr_len++]; + *dst_attr = *attr; + + dst_attr->names[0] = copy_attr_name(format, load_name); + dst_attr->name_len = 1; + dst_attr->offset += format->stride * j; + } + } +} + int GPU_vertformat_attr_id_get(const GPUVertFormat *format, const char *name) { for (int i = 0; i < format->attr_len; i++) { |