wined3d: Cleanup get_flexible_vertex_size().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
51db33ca07
commit
f9d14d6713
|
@ -3016,17 +3016,16 @@ unsigned int CDECL wined3d_device_get_max_frame_latency(const struct wined3d_dev
|
||||||
return device->max_frame_latency;
|
return device->max_frame_latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD get_flexible_vertex_size(DWORD d3dvtVertexType)
|
static unsigned int wined3d_get_flexible_vertex_size(DWORD fvf)
|
||||||
{
|
{
|
||||||
DWORD size = 0;
|
unsigned int texcoord_count = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
|
||||||
int i;
|
unsigned int i, size = 0;
|
||||||
int numTextures = (d3dvtVertexType & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
|
|
||||||
|
|
||||||
if (d3dvtVertexType & WINED3DFVF_NORMAL) size += 3 * sizeof(float);
|
if (fvf & WINED3DFVF_NORMAL) size += 3 * sizeof(float);
|
||||||
if (d3dvtVertexType & WINED3DFVF_DIFFUSE) size += sizeof(DWORD);
|
if (fvf & WINED3DFVF_DIFFUSE) size += sizeof(DWORD);
|
||||||
if (d3dvtVertexType & WINED3DFVF_SPECULAR) size += sizeof(DWORD);
|
if (fvf & WINED3DFVF_SPECULAR) size += sizeof(DWORD);
|
||||||
if (d3dvtVertexType & WINED3DFVF_PSIZE) size += sizeof(DWORD);
|
if (fvf & WINED3DFVF_PSIZE) size += sizeof(DWORD);
|
||||||
switch (d3dvtVertexType & WINED3DFVF_POSITION_MASK)
|
switch (fvf & WINED3DFVF_POSITION_MASK)
|
||||||
{
|
{
|
||||||
case WINED3DFVF_XYZ: size += 3 * sizeof(float); break;
|
case WINED3DFVF_XYZ: size += 3 * sizeof(float); break;
|
||||||
case WINED3DFVF_XYZRHW: size += 4 * sizeof(float); break;
|
case WINED3DFVF_XYZRHW: size += 4 * sizeof(float); break;
|
||||||
|
@ -3036,11 +3035,11 @@ static DWORD get_flexible_vertex_size(DWORD d3dvtVertexType)
|
||||||
case WINED3DFVF_XYZB4: size += 7 * sizeof(float); break;
|
case WINED3DFVF_XYZB4: size += 7 * sizeof(float); break;
|
||||||
case WINED3DFVF_XYZB5: size += 8 * sizeof(float); break;
|
case WINED3DFVF_XYZB5: size += 8 * sizeof(float); break;
|
||||||
case WINED3DFVF_XYZW: size += 4 * sizeof(float); break;
|
case WINED3DFVF_XYZW: size += 4 * sizeof(float); break;
|
||||||
default: FIXME("Unexpected position mask %#x.\n", d3dvtVertexType & WINED3DFVF_POSITION_MASK);
|
default: FIXME("Unexpected position mask %#x.\n", fvf & WINED3DFVF_POSITION_MASK);
|
||||||
}
|
}
|
||||||
for (i = 0; i < numTextures; i++)
|
for (i = 0; i < texcoord_count; ++i)
|
||||||
{
|
{
|
||||||
size += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i) * sizeof(float);
|
size += GET_TEXCOORD_SIZE_FROM_FVF(fvf, i) * sizeof(float);
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -3049,14 +3048,13 @@ static DWORD get_flexible_vertex_size(DWORD d3dvtVertexType)
|
||||||
/* Context activation is done by the caller. */
|
/* Context activation is done by the caller. */
|
||||||
#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
|
#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
|
||||||
static HRESULT process_vertices_strided(const struct wined3d_device *device, DWORD dwDestIndex, DWORD dwCount,
|
static HRESULT process_vertices_strided(const struct wined3d_device *device, DWORD dwDestIndex, DWORD dwCount,
|
||||||
const struct wined3d_stream_info *stream_info, struct wined3d_buffer *dest, DWORD flags,
|
const struct wined3d_stream_info *stream_info, struct wined3d_buffer *dest, DWORD flags, DWORD dst_fvf)
|
||||||
DWORD DestFVF)
|
|
||||||
{
|
{
|
||||||
struct wined3d_matrix mat, proj_mat, view_mat, world_mat;
|
struct wined3d_matrix mat, proj_mat, view_mat, world_mat;
|
||||||
struct wined3d_map_desc map_desc;
|
struct wined3d_map_desc map_desc;
|
||||||
struct wined3d_box box = {0};
|
struct wined3d_box box = {0};
|
||||||
struct wined3d_viewport vp;
|
struct wined3d_viewport vp;
|
||||||
UINT vertex_size;
|
unsigned int vertex_size;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
BYTE *dest_ptr;
|
BYTE *dest_ptr;
|
||||||
BOOL doClip;
|
BOOL doClip;
|
||||||
|
@ -3094,7 +3092,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
|
||||||
else
|
else
|
||||||
doClip = FALSE;
|
doClip = FALSE;
|
||||||
|
|
||||||
vertex_size = get_flexible_vertex_size(DestFVF);
|
vertex_size = wined3d_get_flexible_vertex_size(dst_fvf);
|
||||||
box.left = dwDestIndex * vertex_size;
|
box.left = dwDestIndex * vertex_size;
|
||||||
box.right = box.left + dwCount * vertex_size;
|
box.right = box.left + dwCount * vertex_size;
|
||||||
if (FAILED(hr = wined3d_resource_map(&dest->resource, 0, &map_desc, &box, WINED3D_MAP_WRITE)))
|
if (FAILED(hr = wined3d_resource_map(&dest->resource, 0, &map_desc, &box, WINED3D_MAP_WRITE)))
|
||||||
|
@ -3134,13 +3132,13 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
|
||||||
multiply_matrix(&mat,&view_mat,&world_mat);
|
multiply_matrix(&mat,&view_mat,&world_mat);
|
||||||
multiply_matrix(&mat,&proj_mat,&mat);
|
multiply_matrix(&mat,&proj_mat,&mat);
|
||||||
|
|
||||||
numTextures = (DestFVF & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
|
numTextures = (dst_fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
|
||||||
|
|
||||||
for (i = 0; i < dwCount; i+= 1) {
|
for (i = 0; i < dwCount; i+= 1) {
|
||||||
unsigned int tex_index;
|
unsigned int tex_index;
|
||||||
|
|
||||||
if ( ((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZ ) ||
|
if ( ((dst_fvf & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZ ) ||
|
||||||
((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) ) {
|
((dst_fvf & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) ) {
|
||||||
/* The position first */
|
/* The position first */
|
||||||
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_POSITION];
|
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_POSITION];
|
||||||
const float *p = (const float *)(element->data.addr + i * element->stride);
|
const float *p = (const float *)(element->data.addr + i * element->stride);
|
||||||
|
@ -3235,14 +3233,14 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
|
||||||
|
|
||||||
dest_ptr += 3 * sizeof(float);
|
dest_ptr += 3 * sizeof(float);
|
||||||
|
|
||||||
if ((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW)
|
if ((dst_fvf & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW)
|
||||||
dest_ptr += sizeof(float);
|
dest_ptr += sizeof(float);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DestFVF & WINED3DFVF_PSIZE)
|
if (dst_fvf & WINED3DFVF_PSIZE)
|
||||||
dest_ptr += sizeof(DWORD);
|
dest_ptr += sizeof(DWORD);
|
||||||
|
|
||||||
if (DestFVF & WINED3DFVF_NORMAL)
|
if (dst_fvf & WINED3DFVF_NORMAL)
|
||||||
{
|
{
|
||||||
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_NORMAL];
|
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_NORMAL];
|
||||||
const float *normal = (const float *)(element->data.addr + i * element->stride);
|
const float *normal = (const float *)(element->data.addr + i * element->stride);
|
||||||
|
@ -3251,7 +3249,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
|
||||||
copy_and_next(dest_ptr, normal, 3 * sizeof(float));
|
copy_and_next(dest_ptr, normal, 3 * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DestFVF & WINED3DFVF_DIFFUSE)
|
if (dst_fvf & WINED3DFVF_DIFFUSE)
|
||||||
{
|
{
|
||||||
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_DIFFUSE];
|
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_DIFFUSE];
|
||||||
const DWORD *color_d = (const DWORD *)(element->data.addr + i * element->stride);
|
const DWORD *color_d = (const DWORD *)(element->data.addr + i * element->stride);
|
||||||
|
@ -3273,7 +3271,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DestFVF & WINED3DFVF_SPECULAR)
|
if (dst_fvf & WINED3DFVF_SPECULAR)
|
||||||
{
|
{
|
||||||
/* What's the color value in the feedback buffer? */
|
/* What's the color value in the feedback buffer? */
|
||||||
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_SPECULAR];
|
const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_SPECULAR];
|
||||||
|
@ -3303,11 +3301,11 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
|
||||||
if (!(stream_info->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + tex_index))))
|
if (!(stream_info->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + tex_index))))
|
||||||
{
|
{
|
||||||
ERR("No source texture, but destination requests one\n");
|
ERR("No source texture, but destination requests one\n");
|
||||||
dest_ptr += GET_TEXCOORD_SIZE_FROM_FVF(DestFVF, tex_index) * sizeof(float);
|
dest_ptr += GET_TEXCOORD_SIZE_FROM_FVF(dst_fvf, tex_index) * sizeof(float);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
copy_and_next(dest_ptr, tex_coord, GET_TEXCOORD_SIZE_FROM_FVF(DestFVF, tex_index) * sizeof(float));
|
copy_and_next(dest_ptr, tex_coord, GET_TEXCOORD_SIZE_FROM_FVF(dst_fvf, tex_index) * sizeof(float));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue