From 21b8535902f4d3f92eaca8c762e557d4addd854b Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 28 Nov 2008 15:30:12 +0100 Subject: [PATCH] wined3d: Make the lpData member of WineDirect3DStridedData const. --- dlls/wined3d/drawprim.c | 36 ++++++++++++++++++------------------ dlls/wined3d/state.c | 26 +++++++++++++------------- include/wine/wined3d.idl | 10 +++++----- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index d996bc6c032..35e5390aba3 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -142,7 +142,7 @@ void primitiveDeclarationConvertToStridedData( /* We need to deal with frequency data!*/ - BYTE *data = NULL; + const BYTE *data = NULL; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DVertexDeclarationImpl* vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl; unsigned int i; @@ -299,8 +299,8 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData long SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex; BOOL pixelShader = use_ps(This); - BYTE *texCoords[WINED3DDP_MAXTEXCOORD]; - BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL; + const BYTE *texCoords[WINED3DDP_MAXTEXCOORD]; + const BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL; TRACE("Using slow vertex array code\n"); @@ -409,7 +409,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData if (This->stateBlock->textures[textureNo] != NULL || pixelShader) { int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX]; int texture_idx = This->texUnitMap[textureNo]; - void *ptrToCoords; + const void *ptrToCoords; if (coordIdx > 7) { VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo)); @@ -441,11 +441,11 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData /* Diffuse -------------------------------- */ if (diffuse) { - DWORD *ptrToCoords = (DWORD *)(diffuse + (SkipnStrides * sd->u.s.diffuse.dwStride)); + const void *ptrToCoords = diffuse + SkipnStrides * sd->u.s.diffuse.dwStride; - diffuse_funcs[sd->u.s.diffuse.dwType]((void *) ptrToCoords); + diffuse_funcs[sd->u.s.diffuse.dwType](ptrToCoords); if(This->activeContext->num_untracked_materials) { - DWORD diffuseColor = ptrToCoords[0]; + DWORD diffuseColor = ((const DWORD *)ptrToCoords)[0]; unsigned char i; float color[4]; @@ -462,14 +462,14 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData /* Specular ------------------------------- */ if (specular) { - DWORD *ptrToCoords = (DWORD *)(specular + (SkipnStrides * sd->u.s.specular.dwStride)); + const void *ptrToCoords = specular + SkipnStrides * sd->u.s.specular.dwStride; /* special case where the fog density is stored in the specular alpha channel */ if(This->stateBlock->renderState[WINED3DRS_FOGENABLE] && (This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4 )&& This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) { if(GL_SUPPORT(EXT_FOG_COORD)) { - DWORD specularColor = ptrToCoords[0]; + DWORD specularColor = ((const DWORD *)ptrToCoords)[0]; GL_EXTCALL(glFogCoordfEXT(specularColor >> 24)); } else { static BOOL warned = FALSE; @@ -481,18 +481,18 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData } } - specular_funcs[sd->u.s.specular.dwType]((void *) ptrToCoords); + specular_funcs[sd->u.s.specular.dwType](ptrToCoords); } /* Normal -------------------------------- */ if (normal != NULL) { - float *ptrToCoords = (float *)(normal + (SkipnStrides * sd->u.s.normal.dwStride)); + const void *ptrToCoords = normal + SkipnStrides * sd->u.s.normal.dwStride; normal_funcs[sd->u.s.normal.dwType](ptrToCoords); } /* Position -------------------------------- */ if (position) { - float *ptrToCoords = (float *)(position + (SkipnStrides * sd->u.s.position.dwStride)); + const void *ptrToCoords = position + SkipnStrides * sd->u.s.position.dwStride; position_funcs[sd->u.s.position.dwType](ptrToCoords); } @@ -606,7 +606,7 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, WineDirect3DVertexStridedDa ULONG vx_index; int i; IWineD3DStateBlockImpl *stateblock = This->stateBlock; - BYTE *ptr; + const BYTE *ptr; if (idxSize != 0) { /* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer. @@ -704,7 +704,7 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVerte for(i = 0; i < numInstances; i++) { /* Specify the instanced attributes using immediate mode calls */ for(j = 0; j < numInstancedAttribs; j++) { - BYTE *ptr = sd->u.input[instancedData[j]].lpData + + const BYTE *ptr = sd->u.input[instancedData[j]].lpData + sd->u.input[instancedData[j]].dwStride * i + stateblock->streamOffset[sd->u.input[instancedData[j]].streamNo]; if(sd->u.input[instancedData[j]].VBO) { @@ -1005,7 +1005,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size; float max_x = 0.0, max_y = 0.0, max_z = 0.0, neg_z = 0.0; WineDirect3DVertexStridedData strided; - BYTE *data; + const BYTE *data; WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo; DWORD vtxStride; GLenum feedback_type; @@ -1048,7 +1048,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, /* First, get the boundary cube of the input data */ for(j = 0; j < info->Height; j++) { for(i = 0; i < info->Width; i++) { - float *v = (float *) (data + vtxStride * i + vtxStride * info->Stride * j); + const float *v = (const float *)(data + vtxStride * i + vtxStride * info->Stride * j); if(fabs(v[0]) > max_x) max_x = fabs(v[0]); if(fabs(v[1]) > max_y) max_y = fabs(v[1]); if(fabs(v[2]) > max_z) max_z = fabs(v[2]); @@ -1172,13 +1172,13 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, glMap2f(GL_MAP2_VERTEX_3, 0, 1, vtxStride / sizeof(float), info->Width, 0, 1, info->Stride * vtxStride / sizeof(float), info->Height, - (float *) data); + (const GLfloat *)data); checkGLcall("glMap2f"); if(patch->has_texcoords) { glMap2f(GL_MAP2_TEXTURE_COORD_4, 0, 1, vtxStride / sizeof(float), info->Width, 0, 1, info->Stride * vtxStride / sizeof(float), info->Height, - (float *) data); + (const GLfloat *)data); checkGLcall("glMap2f"); } glMapGrid2f(ceilf(patch->numSegs[0]), 0.0, 1.0, ceilf(patch->numSegs[1]), 0.0, 1.0); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 6e502673c3f..5d8d84a2e2b 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3999,7 +3999,7 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi /* Stride = 0 means always the same values. glVertexAttribPointerARB doesn't do that. Instead disable the pointer and * set up the attribute statically. But we have to figure out the system memory address. */ - BYTE *ptr = strided->u.input[i].lpData + offset[strided->u.input[i].streamNo]; + const BYTE *ptr = strided->u.input[i].lpData + offset[strided->u.input[i].streamNo]; if(strided->u.input[i].VBO) { vb = (IWineD3DVertexBufferImpl *) stateblock->streamSource[strided->u.input[i].streamNo]; ptr += (long) vb->resource.allocatedMemory; @@ -4008,16 +4008,16 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi switch(strided->u.input[i].dwType) { case WINED3DDECLTYPE_FLOAT1: - GL_EXTCALL(glVertexAttrib1fvARB(i, (float *) ptr)); + GL_EXTCALL(glVertexAttrib1fvARB(i, (const GLfloat *)ptr)); break; case WINED3DDECLTYPE_FLOAT2: - GL_EXTCALL(glVertexAttrib2fvARB(i, (float *) ptr)); + GL_EXTCALL(glVertexAttrib2fvARB(i, (const GLfloat *)ptr)); break; case WINED3DDECLTYPE_FLOAT3: - GL_EXTCALL(glVertexAttrib3fvARB(i, (float *) ptr)); + GL_EXTCALL(glVertexAttrib3fvARB(i, (const GLfloat *)ptr)); break; case WINED3DDECLTYPE_FLOAT4: - GL_EXTCALL(glVertexAttrib4fvARB(i, (float *) ptr)); + GL_EXTCALL(glVertexAttrib4fvARB(i, (const GLfloat *)ptr)); break; case WINED3DDECLTYPE_UBYTE4: @@ -4029,38 +4029,38 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi break; case WINED3DDECLTYPE_SHORT2: - GL_EXTCALL(glVertexAttrib4svARB(i, (GLshort *) ptr)); + GL_EXTCALL(glVertexAttrib4svARB(i, (const GLshort *)ptr)); break; case WINED3DDECLTYPE_SHORT4: - GL_EXTCALL(glVertexAttrib4svARB(i, (GLshort *) ptr)); + GL_EXTCALL(glVertexAttrib4svARB(i, (const GLshort *)ptr)); break; case WINED3DDECLTYPE_SHORT2N: { - GLshort s[4] = {((short *) ptr)[0], ((short *) ptr)[1], 0, 1}; + GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1}; GL_EXTCALL(glVertexAttrib4NsvARB(i, s)); break; } case WINED3DDECLTYPE_USHORT2N: { - GLushort s[4] = {((unsigned short *) ptr)[0], ((unsigned short *) ptr)[1], 0, 1}; + GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1}; GL_EXTCALL(glVertexAttrib4NusvARB(i, s)); break; } case WINED3DDECLTYPE_SHORT4N: - GL_EXTCALL(glVertexAttrib4NsvARB(i, (GLshort *) ptr)); + GL_EXTCALL(glVertexAttrib4NsvARB(i, (const GLshort *)ptr)); break; case WINED3DDECLTYPE_USHORT4N: - GL_EXTCALL(glVertexAttrib4NusvARB(i, (GLushort *) ptr)); + GL_EXTCALL(glVertexAttrib4NusvARB(i, (const GLushort *)ptr)); break; case WINED3DDECLTYPE_UDEC3: FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n"); - /*glVertexAttrib3usvARB(i, (GLushort *) ptr); Does not exist */ + /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */ break; case WINED3DDECLTYPE_DEC3N: FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n"); - /*glVertexAttrib3NusvARB(i, (GLushort *) ptr); Does not exist */ + /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */ break; case WINED3DDECLTYPE_FLOAT16_2: diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index bd2826cdf29..29f28c2b376 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -1850,11 +1850,11 @@ typedef struct glDescriptor typedef struct WineDirect3DStridedData { - BYTE *lpData; /* Pointer to start of data */ - DWORD dwStride; /* Stride between occurrences of this data */ - DWORD dwType; /* Type (as in D3DVSDT_TYPE) */ - int VBO; /* Vertex buffer object this data is in */ - UINT streamNo; /* D3D stream number */ + const BYTE *lpData; /* Pointer to start of data */ + DWORD dwStride; /* Stride between occurrences of this data */ + DWORD dwType; /* Type (as in D3DVSDT_TYPE) */ + int VBO; /* Vertex buffer object this data is in */ + UINT streamNo; /* D3D stream number */ } WineDirect3DStridedData; typedef struct WineDirect3DVertexStridedData -- 2.11.4.GIT