summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/nine/device9.c
diff options
context:
space:
mode:
authorTiziano Bacocco <[email protected]>2015-01-30 13:51:44 +0100
committerAxel Davy <[email protected]>2015-02-06 00:07:20 +0100
commit17abefa12be1d5e7d436bfbb082c3eba19adf26c (patch)
tree74543bf82c0b26cd1a1756d0da880ca14fe010cd /src/gallium/state_trackers/nine/device9.c
parent90585cbc9aef27904efc86dbfbd8743d27a6f599 (diff)
st/nine: Implement dummy vbo behaviour when vs is missing inputs
Use a dummy vertex buffer object when vs inputs have no corresponding entries in the vertex declaration. This dummy buffer will give to the shader float4(0,0,0,0). This fixes several artifacts on some games. Signed-off-by: Axel Davy <[email protected]> Signed-off-by: Tiziano Bacocco <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine/device9.c')
-rw-r--r--src/gallium/state_trackers/nine/device9.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index e0524644f8a..78e148bca77 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -221,6 +221,42 @@ NineDevice9_ctor( struct NineDevice9 *This,
NineUnknown_ConvertRefToBind(NineUnknown(This->state.rt[i]));
}
+ /* Initialize a dummy VBO to be used when a a vertex declaration does not
+ * specify all the inputs needed by vertex shader, on win default behavior
+ * is to pass 0,0,0,0 to the shader */
+ {
+ struct pipe_transfer *transfer;
+ struct pipe_resource tmpl;
+ struct pipe_box box;
+ unsigned char *data;
+
+ tmpl.target = PIPE_BUFFER;
+ tmpl.format = PIPE_FORMAT_R8_UNORM;
+ tmpl.width0 = 16; /* 4 floats */
+ tmpl.height0 = 1;
+ tmpl.depth0 = 1;
+ tmpl.array_size = 1;
+ tmpl.last_level = 0;
+ tmpl.nr_samples = 0;
+ tmpl.usage = PIPE_USAGE_DEFAULT;
+ tmpl.bind = PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_TRANSFER_WRITE;
+ tmpl.flags = 0;
+ This->dummy_vbo = pScreen->resource_create(pScreen, &tmpl);
+
+ if (!This->dummy_vbo)
+ return D3DERR_OUTOFVIDEOMEMORY;
+
+ u_box_1d(0, 16, &box);
+ data = This->pipe->transfer_map(This->pipe, This->dummy_vbo, 0,
+ PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
+ &box, &transfer);
+ assert(data);
+ assert(transfer);
+ memset(data, 0, 16);
+ This->pipe->transfer_unmap(This->pipe, transfer);
+ }
+
This->cursor.software = FALSE;
This->cursor.hotspot.x = -1;
This->cursor.hotspot.y = -1;
@@ -387,6 +423,7 @@ NineDevice9_dtor( struct NineDevice9 *This )
pipe_resource_reference(&This->dummy_texture, NULL);
pipe_resource_reference(&This->constbuf_vs, NULL);
pipe_resource_reference(&This->constbuf_ps, NULL);
+ pipe_resource_reference(&This->dummy_vbo, NULL);
FREE(This->state.vs_const_f);
FREE(This->state.ps_const_f);
FREE(This->state.vs_lconstf_temp);