[PATCH 2/5] wined3d: Implement pure integer vertex attributes.
Józef Kucia
jkucia at codeweavers.com
Mon May 30 07:24:10 CDT 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d11/inputlayout.c | 1 +
dlls/d3d8/vertexdeclaration.c | 1 +
dlls/d3d9/vertexdeclaration.c | 1 +
dlls/wined3d/context.c | 1 +
dlls/wined3d/directx.c | 2 ++
dlls/wined3d/state.c | 55 ++++++++++++++++++++++------------------
dlls/wined3d/vertexdeclaration.c | 8 ++++++
dlls/wined3d/wined3d_private.h | 2 ++
include/wine/wined3d.h | 1 +
9 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/dlls/d3d11/inputlayout.c b/dlls/d3d11/inputlayout.c
index e7ba9fd..ef77de5 100644
--- a/dlls/d3d11/inputlayout.c
+++ b/dlls/d3d11/inputlayout.c
@@ -61,6 +61,7 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
}
wined3d_desc->element_count = element_count;
+ wined3d_desc->use_pure_integers = TRUE;
for (i = 0; i < element_count; ++i)
{
struct wined3d_vertex_element *e = &wined3d_desc->elements[i];
diff --git a/dlls/d3d8/vertexdeclaration.c b/dlls/d3d8/vertexdeclaration.c
index d6a1e81..0aa6c8f 100644
--- a/dlls/d3d8/vertexdeclaration.c
+++ b/dlls/d3d8/vertexdeclaration.c
@@ -320,6 +320,7 @@ static HRESULT convert_to_wined3d_declaration_desc(const DWORD *d3d8_elements, D
*d3d8_elements_size = (++token - d3d8_elements) * sizeof(DWORD);
wined3d_desc->element_count = element_count;
+ wined3d_desc->use_pure_integers = FALSE;
return D3D_OK;
}
diff --git a/dlls/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c
index 4510544..8c92ca3 100644
--- a/dlls/d3d9/vertexdeclaration.c
+++ b/dlls/d3d9/vertexdeclaration.c
@@ -343,6 +343,7 @@ static HRESULT convert_to_wined3d_declaration_desc(const D3DVERTEXELEMENT9 *d3d9
}
wined3d_desc->element_count = count;
+ wined3d_desc->use_pure_integers = FALSE;
for (i = 0; i < count; ++i)
{
if (d3d9_elements[i].Type >= (sizeof(d3d_dtype_lookup) / sizeof(*d3d_dtype_lookup)))
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index f07b3ab..d080943 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -3025,6 +3025,7 @@ void context_stream_info_from_declaration(struct wined3d_context *context,
return;
stream_info->position_transformed = declaration->position_transformed;
+ stream_info->use_pure_integers = declaration->use_pure_integers;
/* Translate the declaration into strided data. */
for (i = 0; i < declaration->element_count; ++i)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 9233016..fa376d6 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -3078,6 +3078,7 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info)
USE_GL_FUNC(glVertexAttrib4sv) /* OpenGL 2.0 */
USE_GL_FUNC(glVertexAttrib4ubv) /* OpenGL 2.0 */
USE_GL_FUNC(glVertexAttribDivisor) /* OpenGL 3.3 */
+ USE_GL_FUNC(glVertexAttribIPointer) /* OpenGL 3.0 */
USE_GL_FUNC(glVertexAttribPointer) /* OpenGL 2.0 */
#undef USE_GL_FUNC
@@ -3192,6 +3193,7 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info)
MAP_GL_FUNCTION(glVertexAttrib4sv, glVertexAttrib4svARB);
MAP_GL_FUNCTION(glVertexAttrib4ubv, glVertexAttrib4ubvARB);
MAP_GL_FUNCTION(glVertexAttribDivisor, glVertexAttribDivisorARB);
+ MAP_GL_FUNCTION(glVertexAttribIPointer, glVertexAttribIPointerEXT);
MAP_GL_FUNCTION(glVertexAttribPointer, glVertexAttribPointerARB);
#undef MAP_GL_FUNCTION
#undef MAP_GL_FUNCTION_CAST
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index dabc5cf..4721231 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3965,13 +3965,14 @@ static void load_numbered_arrays(struct wined3d_context *context,
{
const struct wined3d_gl_info *gl_info = context->gl_info;
GLuint curVBO = gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0U : 0;
- int i;
+ unsigned int i;
/* Default to no instancing */
context->instance_count = 0;
- for (i = 0; i < MAX_ATTRIBS; i++)
+ for (i = 0; i < MAX_ATTRIBS; ++i)
{
+ const struct wined3d_stream_info_element *element = &stream_info->elements[i];
const struct wined3d_stream_state *stream;
if (!(stream_info->use_map & (1u << i)))
@@ -3985,16 +3986,16 @@ static void load_numbered_arrays(struct wined3d_context *context,
continue;
}
- stream = &state->streams[stream_info->elements[i].stream_idx];
+ stream = &state->streams[element->stream_idx];
if ((stream->flags & WINED3DSTREAMSOURCE_INSTANCEDATA) && !context->instance_count)
context->instance_count = state->streams[0].frequency ? state->streams[0].frequency : 1;
if (gl_info->supported[ARB_INSTANCED_ARRAYS])
{
- GL_EXTCALL(glVertexAttribDivisor(i, stream_info->elements[i].divisor));
+ GL_EXTCALL(glVertexAttribDivisor(i, element->divisor));
}
- else if (stream_info->elements[i].divisor)
+ else if (element->divisor)
{
/* Unload instanced arrays, they will be loaded using
* immediate mode instead. */
@@ -4003,25 +4004,32 @@ static void load_numbered_arrays(struct wined3d_context *context,
continue;
}
- TRACE_(d3d_shader)("Loading array %u [VBO=%u]\n", i, stream_info->elements[i].data.buffer_object);
+ TRACE_(d3d_shader)("Loading array %u [VBO=%u].\n", i, element->data.buffer_object);
- if (stream_info->elements[i].stride)
+ if (element->stride)
{
- if (curVBO != stream_info->elements[i].data.buffer_object)
+ if (curVBO != element->data.buffer_object)
{
- GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, stream_info->elements[i].data.buffer_object));
+ GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, element->data.buffer_object));
checkGLcall("glBindBuffer");
- curVBO = stream_info->elements[i].data.buffer_object;
+ curVBO = element->data.buffer_object;
}
/* Use the VBO to find out if a vertex buffer exists, not the vb
* pointer. vb can point to a user pointer data blob. In that case
* curVBO will be 0. If there is a vertex buffer but no vbo we
* won't be load converted attributes anyway. */
- GL_EXTCALL(glVertexAttribPointer(i, stream_info->elements[i].format->gl_vtx_format,
- stream_info->elements[i].format->gl_vtx_type,
- stream_info->elements[i].format->gl_normalized,
- stream_info->elements[i].stride, stream_info->elements[i].data.addr
- + state->load_base_vertex_index * stream_info->elements[i].stride));
+ if (stream_info->use_pure_integers
+ && (element->format->flags[WINED3D_GL_RES_TYPE_BUFFER] & WINED3DFMT_FLAG_INTEGER))
+ {
+ GL_EXTCALL(glVertexAttribIPointer(i, element->format->gl_vtx_format, element->format->gl_vtx_type,
+ element->stride, element->data.addr + state->load_base_vertex_index * element->stride));
+ }
+ else
+ {
+ GL_EXTCALL(glVertexAttribPointer(i, element->format->gl_vtx_format, element->format->gl_vtx_type,
+ element->format->gl_normalized, element->stride,
+ element->data.addr + state->load_base_vertex_index * element->stride));
+ }
if (!(context->numbered_array_mask & (1u << i)))
{
@@ -4035,15 +4043,14 @@ static void load_numbered_arrays(struct wined3d_context *context,
* glVertexAttribPointer doesn't do that. Instead disable the
* pointer and set up the attribute statically. But we have to
* figure out the system memory address. */
- const BYTE *ptr = stream_info->elements[i].data.addr;
- if (stream_info->elements[i].data.buffer_object)
- {
+ const BYTE *ptr = element->data.addr;
+ if (element->data.buffer_object)
ptr += (ULONG_PTR)buffer_get_sysmem(stream->buffer, context);
- }
- if (context->numbered_array_mask & (1u << i)) unload_numbered_array(context, i);
+ if (context->numbered_array_mask & (1u << i))
+ unload_numbered_array(context, i);
- switch (stream_info->elements[i].format->id)
+ switch (element->format->id)
{
case WINED3DFMT_R32_FLOAT:
GL_EXTCALL(glVertexAttrib1fv(i, (const GLfloat *)ptr));
@@ -4103,11 +4110,11 @@ static void load_numbered_arrays(struct wined3d_context *context,
break;
case WINED3DFMT_R10G10B10A2_UINT:
- FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
+ FIXME("Unsure about WINED3DDECLTYPE_UDEC3.\n");
/*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
break;
case WINED3DFMT_R10G10B10A2_SNORM:
- FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
+ FIXME("Unsure about WINED3DDECLTYPE_DEC3N.\n");
/*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
break;
@@ -4141,7 +4148,7 @@ static void load_numbered_arrays(struct wined3d_context *context,
break;
default:
- ERR("Unexpected declaration in stride 0 attributes\n");
+ ERR("Unexpected declaration in stride 0 attributes.\n");
break;
}
diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c
index ce2ccad..6c3aba35 100644
--- a/dlls/wined3d/vertexdeclaration.c
+++ b/dlls/wined3d/vertexdeclaration.c
@@ -175,6 +175,12 @@ static HRESULT vertex_declaration_init(struct wined3d_vertex_declaration *declar
dump_wined3d_vertex_element(elements + i);
}
+ if (desc->use_pure_integers && !gl_info->gl_ops.ext.p_glVertexAttribIPointer)
+ {
+ FIXME("OpenGL implementation does not support pure integer vertex attributes.\n");
+ return E_FAIL;
+ }
+
declaration->ref = 1;
declaration->parent = parent;
declaration->parent_ops = parent_ops;
@@ -185,6 +191,7 @@ static HRESULT vertex_declaration_init(struct wined3d_vertex_declaration *declar
return E_OUTOFMEMORY;
}
declaration->element_count = desc->element_count;
+ declaration->use_pure_integers = desc->use_pure_integers;
/* Do some static analysis on the elements to make reading the
* declaration more comfortable for the drawing code. */
@@ -417,6 +424,7 @@ static HRESULT convert_fvf_to_declaration(const struct wined3d_gl_info *gl_info,
desc->elements = state.elements;
desc->element_count = size;
+ desc->use_pure_integers = FALSE;
return WINED3D_OK;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 04f67f2..cb7fddd 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1207,6 +1207,7 @@ struct wined3d_stream_info
struct wined3d_stream_info_element elements[MAX_ATTRIBS];
DWORD position_transformed : 1;
DWORD all_vbo : 1;
+ DWORD use_pure_integers : 1;
WORD swizzle_map; /* MAX_ATTRIBS, 16 */
WORD use_map; /* MAX_ATTRIBS, 16 */
};
@@ -2785,6 +2786,7 @@ struct wined3d_vertex_declaration
BOOL position_transformed;
BOOL half_float_conv_needed;
+ BOOL use_pure_integers;
};
struct wined3d_saved_states
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index d411b8c..2ac9974 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1685,6 +1685,7 @@ struct wined3d_vertex_declaration_desc
{
struct wined3d_vertex_element *elements;
unsigned int element_count;
+ BOOL use_pure_integers;
};
struct wined3d_device_creation_parameters
--
2.7.3
More information about the wine-patches
mailing list