wined3d: Separate mapping from data writing in surface_cpu_blt_colour_fill.
Signed-off-by: Stefan Dösinger <stefan@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
122643b6e2
commit
7bf8b53d57
|
@ -613,3 +613,79 @@ void *resource_offset_map_pointer(struct wined3d_resource *resource, unsigned in
|
|||
+ (box->left * format->byte_count);
|
||||
}
|
||||
}
|
||||
|
||||
void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource,
|
||||
const struct wined3d_map_desc *map, const struct wined3d_color *colour,
|
||||
const struct wined3d_box *box)
|
||||
{
|
||||
const struct wined3d_format *format = resource->format;
|
||||
unsigned int w, h, d, x, y, z, bpp;
|
||||
uint8_t *dst, *dst2;
|
||||
uint32_t c;
|
||||
|
||||
w = box->right - box->left;
|
||||
h = box->bottom - box->top;
|
||||
d = box->back - box->front;
|
||||
|
||||
dst = (uint8_t *)map->data
|
||||
+ (box->front * map->slice_pitch)
|
||||
+ ((box->top / format->block_height) * map->row_pitch)
|
||||
+ ((box->left / format->block_width) * format->block_byte_count);
|
||||
|
||||
c = wined3d_format_convert_from_float(format, colour);
|
||||
bpp = format->byte_count;
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
case 1:
|
||||
for (x = 0; x < w; ++x)
|
||||
{
|
||||
dst[x] = c;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (x = 0; x < w; ++x)
|
||||
{
|
||||
((uint16_t *)dst)[x] = c;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
dst2 = dst;
|
||||
for (x = 0; x < w; ++x, dst2 += 3)
|
||||
{
|
||||
dst2[0] = (c ) & 0xff;
|
||||
dst2[1] = (c >> 8) & 0xff;
|
||||
dst2[2] = (c >> 16) & 0xff;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
for (x = 0; x < w; ++x)
|
||||
{
|
||||
((uint32_t *)dst)[x] = c;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Not implemented for bpp %u.\n", bpp);
|
||||
return;
|
||||
}
|
||||
|
||||
dst2 = dst;
|
||||
for (y = 1; y < h; ++y)
|
||||
{
|
||||
dst2 += map->row_pitch;
|
||||
memcpy(dst2, dst, w * bpp);
|
||||
}
|
||||
|
||||
dst2 = dst;
|
||||
for (z = 1; z < d; ++z)
|
||||
{
|
||||
dst2 += map->slice_pitch;
|
||||
memcpy(dst2, dst, w * h * bpp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1241,15 +1241,13 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view,
|
|||
const struct wined3d_box *box, const struct wined3d_color *colour)
|
||||
{
|
||||
struct wined3d_device *device = view->resource->device;
|
||||
unsigned int x, y, z, w, h, d, bpp, level;
|
||||
struct wined3d_context *context;
|
||||
struct wined3d_texture *texture;
|
||||
struct wined3d_bo_address data;
|
||||
struct wined3d_map_desc map;
|
||||
struct wined3d_range range;
|
||||
unsigned int level;
|
||||
DWORD map_binding;
|
||||
uint8_t *dst;
|
||||
DWORD c;
|
||||
|
||||
TRACE("view %p, box %s, colour %s.\n", view, debug_box(box), debug_color(colour));
|
||||
|
||||
|
@ -1274,12 +1272,6 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view,
|
|||
texture = texture_from_resource(view->resource);
|
||||
level = view->sub_resource_idx % texture->level_count;
|
||||
|
||||
c = wined3d_format_convert_from_float(view->format, colour);
|
||||
bpp = view->format->byte_count;
|
||||
w = box->right - box->left;
|
||||
h = box->bottom - box->top;
|
||||
d = box->back - box->front;
|
||||
|
||||
map_binding = texture->resource.map_binding;
|
||||
if (!wined3d_texture_load_location(texture, view->sub_resource_idx, context, map_binding))
|
||||
ERR("Failed to load the sub-resource into %s.\n", wined3d_debug_location(map_binding));
|
||||
|
@ -1288,66 +1280,10 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view,
|
|||
wined3d_texture_get_bo_address(texture, view->sub_resource_idx, &data, map_binding);
|
||||
map.data = wined3d_context_map_bo_address(context, &data,
|
||||
texture->sub_resources[view->sub_resource_idx].size, WINED3D_MAP_WRITE);
|
||||
map.data = (BYTE *)map.data
|
||||
+ (box->front * map.slice_pitch)
|
||||
+ ((box->top / view->format->block_height) * map.row_pitch)
|
||||
+ ((box->left / view->format->block_width) * view->format->block_byte_count);
|
||||
range.offset = 0;
|
||||
range.size = texture->sub_resources[view->sub_resource_idx].size;
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
case 1:
|
||||
for (x = 0; x < w; ++x)
|
||||
{
|
||||
((BYTE *)map.data)[x] = c;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (x = 0; x < w; ++x)
|
||||
{
|
||||
((WORD *)map.data)[x] = c;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
dst = map.data;
|
||||
for (x = 0; x < w; ++x, dst += 3)
|
||||
{
|
||||
dst[0] = (c ) & 0xff;
|
||||
dst[1] = (c >> 8) & 0xff;
|
||||
dst[2] = (c >> 16) & 0xff;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
for (x = 0; x < w; ++x)
|
||||
{
|
||||
((DWORD *)map.data)[x] = c;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Not implemented for bpp %u.\n", bpp);
|
||||
wined3d_resource_unmap(view->resource, view->sub_resource_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
dst = map.data;
|
||||
for (y = 1; y < h; ++y)
|
||||
{
|
||||
dst += map.row_pitch;
|
||||
memcpy(dst, map.data, w * bpp);
|
||||
}
|
||||
|
||||
dst = map.data;
|
||||
for (z = 1; z < d; ++z)
|
||||
{
|
||||
dst += map.slice_pitch;
|
||||
memcpy(dst, map.data, w * h * bpp);
|
||||
}
|
||||
wined3d_resource_memory_colour_fill(view->resource, &map, colour, box);
|
||||
|
||||
wined3d_context_unmap_bo_address(context, &data, 1, &range);
|
||||
context_release(context);
|
||||
|
|
|
@ -4365,6 +4365,9 @@ GLbitfield wined3d_resource_gl_storage_flags(const struct wined3d_resource *reso
|
|||
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||
BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||
void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||
void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource,
|
||||
const struct wined3d_map_desc *map, const struct wined3d_color *colour,
|
||||
const struct wined3d_box *box) DECLSPEC_HIDDEN;
|
||||
|
||||
/* Tests show that the start address of resources is 32 byte aligned */
|
||||
#define RESOURCE_ALIGNMENT 16
|
||||
|
|
Loading…
Reference in New Issue