wined3d: Move base vertex state to wined3d_state.
This commit is contained in:
parent
902630efb5
commit
98a91e84bc
|
@ -220,12 +220,13 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
|
|||
* sources. In most sane cases the pointer - offset will still be > 0, otherwise it will wrap
|
||||
* around to some big value. Hope that with the indices, the driver wraps it back internally. If
|
||||
* not, drawStridedSlow is needed, including a vertex buffer path. */
|
||||
if (This->stateBlock->loadBaseVertexIndex < 0)
|
||||
if (This->stateBlock->state.load_base_vertex_index < 0)
|
||||
{
|
||||
WARN("loadBaseVertexIndex is < 0 (%d), not using vbos\n", This->stateBlock->loadBaseVertexIndex);
|
||||
WARN("load_base_vertex_index is < 0 (%d), not using VBOs.\n",
|
||||
This->stateBlock->state.load_base_vertex_index);
|
||||
buffer_object = 0;
|
||||
data = buffer_get_sysmem(buffer, &This->adapter->gl_info);
|
||||
if ((UINT_PTR)data < -This->stateBlock->loadBaseVertexIndex * stride)
|
||||
if ((UINT_PTR)data < -This->stateBlock->state.load_base_vertex_index * stride)
|
||||
{
|
||||
FIXME("System memory vertex data load offset is negative!\n");
|
||||
}
|
||||
|
@ -2974,12 +2975,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetBaseVertexIndex(IWineD3DDevice *ifac
|
|||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||
TRACE("(%p)->(%d)\n", This, BaseIndex);
|
||||
|
||||
if(This->updateStateBlock->baseVertexIndex == BaseIndex) {
|
||||
if (This->updateStateBlock->state.base_vertex_index == BaseIndex)
|
||||
{
|
||||
TRACE("Application is setting the old value over, nothing to do\n");
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
This->updateStateBlock->baseVertexIndex = BaseIndex;
|
||||
This->updateStateBlock->state.base_vertex_index = BaseIndex;
|
||||
|
||||
if (This->isRecordingState) {
|
||||
TRACE("Recording... not performing anything\n");
|
||||
|
@ -2994,7 +2996,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetBaseVertexIndex(IWineD3DDevice *ifac
|
|||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||
TRACE("(%p) : base_index %p\n", This, base_index);
|
||||
|
||||
*base_index = This->stateBlock->baseVertexIndex;
|
||||
*base_index = This->stateBlock->state.base_vertex_index;
|
||||
|
||||
TRACE("Returning %u\n", *base_index);
|
||||
|
||||
|
@ -4687,9 +4689,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, UI
|
|||
This->stateBlock->state.user_stream = FALSE;
|
||||
}
|
||||
|
||||
if (This->stateBlock->loadBaseVertexIndex)
|
||||
if (This->stateBlock->state.load_base_vertex_index)
|
||||
{
|
||||
This->stateBlock->loadBaseVertexIndex = 0;
|
||||
This->stateBlock->state.load_base_vertex_index = 0;
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
|
||||
}
|
||||
/* Account for the loading offset due to index buffers. Instead of reloading all sources correct it with the startvertex parameter */
|
||||
|
@ -4735,8 +4737,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *if
|
|||
else
|
||||
idxStride = 4;
|
||||
|
||||
if(This->stateBlock->loadBaseVertexIndex != This->stateBlock->baseVertexIndex) {
|
||||
This->stateBlock->loadBaseVertexIndex = This->stateBlock->baseVertexIndex;
|
||||
if (This->stateBlock->state.load_base_vertex_index != This->stateBlock->state.base_vertex_index)
|
||||
{
|
||||
This->stateBlock->state.load_base_vertex_index = This->stateBlock->state.base_vertex_index;
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
|
||||
}
|
||||
|
||||
|
@ -4770,7 +4773,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface,
|
|||
stream->offset = 0;
|
||||
stream->stride = VertexStreamZeroStride;
|
||||
This->stateBlock->state.user_stream = TRUE;
|
||||
This->stateBlock->loadBaseVertexIndex = 0;
|
||||
This->stateBlock->state.load_base_vertex_index = 0;
|
||||
|
||||
/* TODO: Only mark dirty if drawing from a different UP address */
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
|
||||
|
@ -4821,8 +4824,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
|
|||
This->stateBlock->state.user_stream = TRUE;
|
||||
|
||||
/* Set to 0 as per msdn. Do it now due to the stream source loading during drawPrimitive */
|
||||
This->stateBlock->baseVertexIndex = 0;
|
||||
This->stateBlock->loadBaseVertexIndex = 0;
|
||||
This->stateBlock->state.base_vertex_index = 0;
|
||||
This->stateBlock->state.load_base_vertex_index = 0;
|
||||
/* Mark the state dirty until we have nicer tracking of the stream source pointers */
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
|
||||
|
@ -4856,7 +4859,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *if
|
|||
*/
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
|
||||
This->stateBlock->baseVertexIndex = 0;
|
||||
This->stateBlock->state.base_vertex_index = 0;
|
||||
This->up_strided = DrawPrimStrideData;
|
||||
drawPrimitive(iface, vertex_count, 0, 0, NULL);
|
||||
This->up_strided = NULL;
|
||||
|
@ -4877,7 +4880,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDev
|
|||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
|
||||
This->stateBlock->state.user_stream = TRUE;
|
||||
This->stateBlock->baseVertexIndex = 0;
|
||||
This->stateBlock->state.base_vertex_index = 0;
|
||||
This->up_strided = DrawPrimStrideData;
|
||||
drawPrimitive(iface, vertex_count, 0 /* start_idx */, idxSize, pIndexData);
|
||||
This->up_strided = NULL;
|
||||
|
|
|
@ -70,7 +70,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
|
|||
UINT vx_index;
|
||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||
const struct wined3d_stream_state *streams = This->stateBlock->state.streams;
|
||||
LONG SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex;
|
||||
LONG SkipnStrides = startIdx + This->stateBlock->state.load_base_vertex_index;
|
||||
BOOL pixelShader = use_ps(This->stateBlock);
|
||||
BOOL specular_fog = FALSE;
|
||||
const BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
|
||||
|
@ -225,9 +225,9 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
|
|||
{
|
||||
/* Indexed so work out the number of strides to skip */
|
||||
if (idxSize == 2)
|
||||
SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
|
||||
SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->state.load_base_vertex_index;
|
||||
else
|
||||
SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
|
||||
SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->state.load_base_vertex_index;
|
||||
}
|
||||
|
||||
tmp_tex_mask = tex_mask;
|
||||
|
@ -422,9 +422,9 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream
|
|||
{
|
||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
|
||||
const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
|
||||
LONG SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex;
|
||||
const WORD *pIdxBufS = NULL;
|
||||
const DWORD *pIdxBufL = NULL;
|
||||
LONG SkipnStrides = startIdx + This->stateBlock->state.load_base_vertex_index;
|
||||
const DWORD *pIdxBufL = NULL;
|
||||
const WORD *pIdxBufS = NULL;
|
||||
UINT vx_index;
|
||||
int i;
|
||||
IWineD3DStateBlockImpl *stateblock = This->stateBlock;
|
||||
|
@ -455,9 +455,9 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream
|
|||
{
|
||||
/* Indexed so work out the number of strides to skip */
|
||||
if (idxSize == 2)
|
||||
SkipnStrides = pIdxBufS[startIdx + vx_index] + stateblock->loadBaseVertexIndex;
|
||||
SkipnStrides = pIdxBufS[startIdx + vx_index] + stateblock->state.load_base_vertex_index;
|
||||
else
|
||||
SkipnStrides = pIdxBufL[startIdx + vx_index] + stateblock->loadBaseVertexIndex;
|
||||
SkipnStrides = pIdxBufL[startIdx + vx_index] + stateblock->state.load_base_vertex_index;
|
||||
}
|
||||
|
||||
for (i = MAX_ATTRIBS - 1; i >= 0; i--)
|
||||
|
|
|
@ -3350,7 +3350,7 @@ static void loadTexCoords(const struct wined3d_gl_info *gl_info, IWineD3DStateBl
|
|||
|
||||
/* The coords to supply depend completely on the fvf / vertex shader */
|
||||
glTexCoordPointer(e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
} else {
|
||||
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + mapped_stage, 0, 0, 0, 1));
|
||||
|
@ -4187,7 +4187,7 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
|
|||
stream_info->elements[i].format->gl_vtx_type,
|
||||
stream_info->elements[i].format->gl_normalized,
|
||||
vb->conversion_stride, stream_info->elements[i].data + vb->conversion_shift[shift_index]
|
||||
+ stateblock->loadBaseVertexIndex * stream_info->elements[i].stride
|
||||
+ stateblock->state.load_base_vertex_index * stream_info->elements[i].stride
|
||||
+ stream->offset));
|
||||
|
||||
} else {
|
||||
|
@ -4195,7 +4195,7 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
|
|||
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
|
||||
+ stateblock->loadBaseVertexIndex * stream_info->elements[i].stride
|
||||
+ stateblock->state.load_base_vertex_index * stream_info->elements[i].stride
|
||||
+ stream->offset));
|
||||
}
|
||||
|
||||
|
@ -4332,7 +4332,7 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
|
|||
if (gl_info->supported[ARB_VERTEX_BLEND])
|
||||
{
|
||||
TRACE("Blend %u %p %u\n", e->format->component_count,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride, e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride, e->stride + stream->offset);
|
||||
|
||||
glEnableClientState(GL_WEIGHT_ARRAY_ARB);
|
||||
checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
|
||||
|
@ -4350,9 +4350,9 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
|
|||
e->format->gl_vtx_format,
|
||||
e->format->gl_vtx_type,
|
||||
e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
GL_EXTCALL(glWeightPointerARB(e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset));
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset));
|
||||
|
||||
checkGLcall("glWeightPointerARB");
|
||||
|
||||
|
@ -4414,17 +4414,17 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
|
|||
if (!e->buffer_object)
|
||||
{
|
||||
TRACE("glVertexPointer(3, %#x, %#x, %p);\n", e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
glVertexPointer(3 /* min(e->format->gl_vtx_format, 3) */, e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n",
|
||||
e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
glVertexPointer(e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
}
|
||||
checkGLcall("glVertexPointer(...)");
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
@ -4445,9 +4445,9 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
|
|||
}
|
||||
|
||||
TRACE("glNormalPointer(%#x, %#x, %p);\n", e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
glNormalPointer(e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
checkGLcall("glNormalPointer(...)");
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
|
||||
|
@ -4480,9 +4480,9 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
|
|||
|
||||
TRACE("glColorPointer(%#x, %#x %#x, %p);\n",
|
||||
e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
glColorPointer(e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
|
||||
|
@ -4520,9 +4520,9 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
|
|||
* 4 component secondary colors use it
|
||||
*/
|
||||
TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format, type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
GL_EXTCALL(glSecondaryColorPointerEXT(format, type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset));
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset));
|
||||
checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
|
||||
}
|
||||
else
|
||||
|
@ -4531,9 +4531,9 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
|
|||
{
|
||||
case GL_UNSIGNED_BYTE:
|
||||
TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset));
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset));
|
||||
checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
|
||||
break;
|
||||
|
||||
|
@ -4541,9 +4541,9 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
|
|||
FIXME("Add 4 component specular color pointers for type %x\n", type);
|
||||
/* Make sure that the right color component is dropped */
|
||||
TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset);
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset);
|
||||
GL_EXTCALL(glSecondaryColorPointerEXT(3, type, e->stride,
|
||||
e->data + stateblock->loadBaseVertexIndex * e->stride + stream->offset));
|
||||
e->data + stateblock->state.load_base_vertex_index * e->stride + stream->offset));
|
||||
checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -722,18 +722,18 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
|
|||
|
||||
if (This->changed.indices
|
||||
&& ((This->state.index_buffer != targetStateBlock->state.index_buffer)
|
||||
|| (This->baseVertexIndex != targetStateBlock->baseVertexIndex)
|
||||
|| (This->state.base_vertex_index != targetStateBlock->state.base_vertex_index)
|
||||
|| (This->state.index_format != targetStateBlock->state.index_format)))
|
||||
{
|
||||
TRACE("Updating index buffer to %p, baseVertexIndex to %d.\n",
|
||||
targetStateBlock->state.index_buffer, targetStateBlock->baseVertexIndex);
|
||||
targetStateBlock->state.index_buffer, targetStateBlock->state.base_vertex_index);
|
||||
|
||||
if (targetStateBlock->state.index_buffer)
|
||||
IWineD3DBuffer_AddRef((IWineD3DBuffer *)targetStateBlock->state.index_buffer);
|
||||
if (This->state.index_buffer)
|
||||
IWineD3DBuffer_Release((IWineD3DBuffer *)This->state.index_buffer);
|
||||
This->state.index_buffer = targetStateBlock->state.index_buffer;
|
||||
This->baseVertexIndex = targetStateBlock->baseVertexIndex;
|
||||
This->state.base_vertex_index = targetStateBlock->state.base_vertex_index;
|
||||
This->state.index_format = targetStateBlock->state.index_format;
|
||||
}
|
||||
|
||||
|
@ -1001,7 +1001,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
|
|||
if (This->changed.indices)
|
||||
{
|
||||
IWineD3DDevice_SetIndexBuffer(device, (IWineD3DBuffer *)This->state.index_buffer, This->state.index_format);
|
||||
IWineD3DDevice_SetBaseVertexIndex(device, This->baseVertexIndex);
|
||||
IWineD3DDevice_SetBaseVertexIndex(device, This->state.base_vertex_index);
|
||||
}
|
||||
|
||||
if (This->changed.vertexDecl && This->state.vertex_declaration)
|
||||
|
|
|
@ -2354,6 +2354,8 @@ struct wined3d_state
|
|||
BOOL user_stream;
|
||||
struct wined3d_buffer *index_buffer;
|
||||
enum wined3d_format_id index_format;
|
||||
INT base_vertex_index;
|
||||
INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
|
||||
|
||||
struct IWineD3DVertexShaderImpl *vertex_shader;
|
||||
BOOL vs_consts_b[MAX_CONST_B];
|
||||
|
@ -2395,9 +2397,6 @@ struct IWineD3DStateBlockImpl
|
|||
/* primitive type */
|
||||
GLenum gl_primitive_type;
|
||||
|
||||
INT baseVertexIndex;
|
||||
INT loadBaseVertexIndex; /* non-indexed drawing needs 0 here, indexed baseVertexIndex */
|
||||
|
||||
/* Light hashmap . Collisions are handled using standard wine double linked lists */
|
||||
#define LIGHTMAP_SIZE 43 /* Use of a prime number recommended. Set to 1 for a linked list! */
|
||||
#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE) /* Primitive and simple function */
|
||||
|
|
Loading…
Reference in New Issue