aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCourtney Goeltzenleuchter <courtney@LunarG.com>2015-03-31 16:36:30 -0600
committerChia-I Wu <olv@lunarg.com>2015-04-16 17:33:27 +0800
commit65af4b6be76afba4bc1d9d334c9c956ab6089b6f (patch)
treef7712958e670217a52a1be88859954b8b88e6ccd
parent8e777be1bb338082769c8d764e8a5331f0009e9d (diff)
downloadusermoji-65af4b6be76afba4bc1d9d334c9c956ab6089b6f.tar.xz
xgl: Update interface for sparse vertex attrs
Bug #13402 header version: 0.64.0
-rw-r--r--demos/tri.c23
-rw-r--r--include/xgl.h6
2 files changed, 19 insertions, 10 deletions
diff --git a/demos/tri.c b/demos/tri.c
index 7c312a79..b5f1387d 100644
--- a/demos/tri.c
+++ b/demos/tri.c
@@ -19,6 +19,7 @@
#define DEMO_BUFFER_COUNT 2
#define DEMO_TEXTURE_COUNT 1
+#define VERTEX_BUFFER_BIND_ID 0
struct texture_object {
XGL_SAMPLER sampler;
@@ -278,7 +279,7 @@ static void demo_draw_build_cmd(struct demo *demo)
demo->depth_stencil);
- xglCmdBindVertexBuffer(demo->cmd, demo->vertices.buf, 0, 0);
+ xglCmdBindVertexBuffer(demo->cmd, demo->vertices.buf, 0, VERTEX_BUFFER_BIND_ID);
xglCmdBeginRenderPass(demo->cmd, &rp_begin);
clear_range.aspect = XGL_IMAGE_ASPECT_COLOR;
@@ -827,14 +828,17 @@ static void demo_prepare_vertices(struct demo *demo)
demo->vertices.vi.attributeCount = 2;
demo->vertices.vi.pVertexAttributeDescriptions = demo->vertices.vi_attrs;
+ demo->vertices.vi_bindings[0].binding = VERTEX_BUFFER_BIND_ID;
demo->vertices.vi_bindings[0].strideInBytes = sizeof(vb[0]);
demo->vertices.vi_bindings[0].stepRate = XGL_VERTEX_INPUT_STEP_RATE_VERTEX;
- demo->vertices.vi_attrs[0].binding = 0;
+ demo->vertices.vi_attrs[0].binding = VERTEX_BUFFER_BIND_ID;
+ demo->vertices.vi_attrs[0].location = 0;
demo->vertices.vi_attrs[0].format = XGL_FMT_R32G32B32_SFLOAT;
demo->vertices.vi_attrs[0].offsetInBytes = 0;
- demo->vertices.vi_attrs[1].binding = 0;
+ demo->vertices.vi_attrs[1].binding = VERTEX_BUFFER_BIND_ID;
+ demo->vertices.vi_attrs[1].location = 1;
demo->vertices.vi_attrs[1].format = XGL_FMT_R32G32_SFLOAT;
demo->vertices.vi_attrs[1].offsetInBytes = sizeof(float) * 3;
}
@@ -896,9 +900,10 @@ static XGL_SHADER demo_prepare_vs(struct demo *demo)
{
static const char *vertShaderText =
"#version 140\n"
- "#extension GL_ARB_explicit_attrib_location : require\n"
- "layout(location = 0) in vec4 pos;\n"
- "layout(location = 1) in vec2 attr;\n"
+ "#extension GL_ARB_separate_shader_objects : enable\n"
+ "#extension GL_ARB_shading_language_420pack : enable\n"
+ "layout (location = 0) in vec4 pos;\n"
+ "layout (location = 1) in vec2 attr;\n"
"out vec2 texcoord;\n"
"void main() {\n"
" texcoord = attr;\n"
@@ -914,8 +919,10 @@ static XGL_SHADER demo_prepare_fs(struct demo *demo)
{
static const char *fragShaderText =
"#version 140\n"
- "uniform sampler2D tex;\n"
- "in vec2 texcoord;\n"
+ "#extension GL_ARB_separate_shader_objects : enable\n"
+ "#extension GL_ARB_shading_language_420pack : enable\n"
+ "layout (binding = 0) uniform sampler2D tex;\n"
+ "layout (location = 0) in vec2 texcoord;\n"
"void main() {\n"
" gl_FragColor = texture(tex, texcoord);\n"
"}\n";
diff --git a/include/xgl.h b/include/xgl.h
index 8e7aa161..c9c27917 100644
--- a/include/xgl.h
+++ b/include/xgl.h
@@ -33,7 +33,7 @@
#include "xglPlatform.h"
// XGL API version supported by this file
-#define XGL_API_VERSION XGL_MAKE_VERSION(0, 63, 0)
+#define XGL_API_VERSION XGL_MAKE_VERSION(0, 64, 0)
#ifdef __cplusplus
extern "C"
@@ -1879,6 +1879,7 @@ typedef struct _XGL_COMPUTE_PIPELINE_CREATE_INFO
typedef struct _XGL_VERTEX_INPUT_BINDING_DESCRIPTION
{
+ uint32_t binding; // Vertex buffer binding id
uint32_t strideInBytes; // Distance between vertices in bytes (0 = no advancement)
XGL_VERTEX_INPUT_STEP_RATE stepRate; // Rate at which binding is incremented
@@ -1886,7 +1887,8 @@ typedef struct _XGL_VERTEX_INPUT_BINDING_DESCRIPTION
typedef struct _XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION
{
- uint32_t binding; // index into vertexBindingDescriptions
+ uint32_t location; // location of the shader vertex attrib
+ uint32_t binding; // Vertex buffer binding id
XGL_FORMAT format; // format of source data