57 f->l = ((
r->left * 2.0f) /
w) - 1.0f;
58 f->t = ((
r->top * 2.0f) /
h) - 1.0f;
59 f->r = ((
r->right * 2.0f) /
w) - 1.0f;
60 f->b = ((
r->bottom * 2.0f) /
h) - 1.0f;
197 gl_info->
gl_ops.gl.p_glEnable(
info.bind_target);
217 gl_info->
gl_ops.gl.p_glTexCoord3fv(&
info.texcoords[0].x);
218 gl_info->
gl_ops.gl.p_glVertex2i(dst_rect->
left, dst_rect->
top);
220 gl_info->
gl_ops.gl.p_glTexCoord3fv(&
info.texcoords[1].x);
223 gl_info->
gl_ops.gl.p_glTexCoord3fv(&
info.texcoords[2].x);
226 gl_info->
gl_ops.gl.p_glTexCoord3fv(&
info.texcoords[3].x);
228 gl_info->
gl_ops.gl.p_glEnd();
254 if ((
r->left &&
r->right) ||
abs(
r->right -
r->left) !=
t)
257 if ((
r->top &&
r->bottom) ||
abs(
r->bottom -
r->top) !=
t)
276 TRACE(
"src_surface %p, src_location %s, src_rect %s,\n",
278 TRACE(
"dst_surface %p, dst_location %s, dst_rect %s.\n",
286 ERR(
"Incompatible formats %s and %s.\n",
294 ERR(
"Not a depth / stencil format: %s.\n",
309 WARN(
"Invalid context, skipping blit.\n");
343 gl_info->gl_ops.gl.p_glStencilMask(~0
U);
355 gl_info->gl_ops.gl.p_glFlush();
383 RECT src_rect, dst_rect;
389 TRACE(
"src_surface %p, src_location %s, src_rect %s,\n",
391 TRACE(
"dst_surface %p, dst_location %s, dst_rect %s.\n",
394 src_rect = *src_rect_in;
395 dst_rect = *dst_rect_in;
431 else required_rt =
NULL;
434 if (restore_rt != required_rt)
443 WARN(
"Invalid context, skipping blit.\n");
451 TRACE(
"Source surface %p is onscreen.\n", src_surface);
457 TRACE(
"Source surface %p is offscreen.\n", src_surface);
468 TRACE(
"Destination surface %p is onscreen.\n", dst_surface);
474 TRACE(
"Destination surface %p is offscreen.\n", dst_surface);
495 && dst_texture->
swapchain->front_buffer == dst_texture))
496 gl_info->
gl_ops.gl.p_glFlush();
559 struct wined3d_texture_sub_resource *sub_resource;
560 unsigned int dst_row_pitch, dst_slice_pitch;
561 unsigned int src_row_pitch, src_slice_pitch;
575 sub_resource = &
texture->sub_resources[sub_resource_idx];
583 FIXME(
"Reading back converted array texture %p is not supported.\n",
texture);
589 ERR(
"Array texture %p uses NP2 emulation.\n",
texture);
591 WARN_(d3d_perf)(
"Downloading all miplevel layers to get the surface data for a single sub-resource.\n");
595 ERR(
"Out of memory.\n");
606 FIXME(
"Reading back converted texture %p with NP2 emulation is not supported.\n",
texture);
614 &src_row_pitch, &src_slice_pitch);
615 if (!(temporary_mem =
heap_alloc(src_slice_pitch)))
617 ERR(
"Out of memory.\n");
621 if (
data.buffer_object)
622 ERR(
"NP2 emulated texture uses PBO unexpectedly.\n");
624 ERR(
"Unexpected compressed format for NP2 emulated texture.\n");
631 if (
data.buffer_object)
632 ERR(
"Converted texture %p uses PBO unexpectedly.\n",
texture);
637 f.byte_count =
format->conv_byte_count;
642 &src_row_pitch, &src_slice_pitch);
644 if (!(temporary_mem =
heap_alloc(src_slice_pitch)))
646 ERR(
"Failed to allocate memory.\n");
655 else if (
data.buffer_object)
668 TRACE(
"Downloading compressed surface %p, level %u, format %#x, type %#x, data %p.\n",
676 TRACE(
"Downloading surface %p, level %u, format %#x, type %#x, data %p.\n",
685 format->download(
mem,
data.addr, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
691 const BYTE *src_data;
740 dst_data =
data.addr;
741 TRACE(
"Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_row_pitch);
743 for (
y = 0;
y <
h; ++
y)
745 memcpy(dst_data, src_data, dst_row_pitch);
746 src_data += src_row_pitch;
747 dst_data += dst_row_pitch;
750 else if (temporary_mem)
752 unsigned int layer = sub_resource_idx /
texture->level_count;
753 void *src_data = temporary_mem +
layer * sub_resource->size;
754 if (
data.buffer_object)
763 memcpy(
data.addr, src_data, sub_resource->size);
767 if (
data.buffer_object)
790 TRACE(
"surface %p, gl_info %p, format %s, src_rect %s, src_pitch %u, dst_point %s, srgb %#x, data {%#x:%p}.\n",
794 if (
texture->sub_resources[sub_resource_idx].map_count)
796 WARN(
"Uploading a surface that is currently mapped, setting WINED3D_TEXTURE_PIN_SYSMEM.\n");
802 update_h *=
format->height_scale.numerator;
803 update_h /=
format->height_scale.denominator;
806 if (
data->buffer_object)
818 unsigned int dst_row_pitch, dst_slice_pitch;
835 TRACE(
"Uploading compressed data, target %#x, level %u, layer %u, x %d, y %d, w %u, h %u, "
836 "format %#x, image_size %#x, addr %p.\n",
840 if (dst_row_pitch == src_pitch)
855 UINT row_count = (update_h +
format->block_height - 1) /
format->block_height;
883 addr += src_rect->
top * src_pitch;
886 TRACE(
"Uploading data, target %#x, level %u, layer %u, x %d, y %d, w %u, h %u, "
887 "format %#x, type %#x, addr %p.\n",
906 if (
data->buffer_object)
913 gl_info->
gl_ops.gl.p_glFlush();
920 for (
i = 0;
i <
device->context_count; ++
i)
934 unsigned int src_row_pitch, src_slice_pitch;
936 unsigned int src_level, dst_level;
939 UINT update_w, update_h;
941 TRACE(
"dst_surface %p, dst_point %s, src_surface %p, src_rect %s.\n",
951 update_w = src_rect->
right - src_rect->
left;
952 update_h = src_rect->
bottom - src_rect->
top;
953 dst_level = dst_sub_resource_idx % dst_texture->
level_count;
961 src_level = src_sub_resource_idx % src_texture->
level_count;
987 unsigned int src_width, src_height;
991 gl_info = &
texture->resource.device->adapter->gl_info;
998 unsigned int rt_level;
1021 if (
width > src_width ||
height > src_height)
return;
1066 unsigned int mantissa;
1075 return (*
in < 0.0f ? 0xfc00 : 0x7c00);
1077 if (tmp < (
float)(1u << 10))
1083 }
while (tmp < (
float)(1u << 10));
1085 else if (tmp >= (
float)(1u << 11))
1091 }
while (tmp >= (
float)(1u << 11));
1094 mantissa = (
unsigned int)tmp;
1095 if (tmp - mantissa >= 0.5f)
1110 mantissa = mantissa >> 1;
1113 ret = mantissa & 0x3ff;
1117 ret = (
exp << 10) | (mantissa & 0x3ff);
1120 ret |= ((*
in < 0.0f ? 1 : 0) << 15);
1125 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1127 unsigned short *dst_s;
1131 TRACE(
"Converting %ux%u pixels, pitches %u %u.\n",
w,
h, pitch_in, pitch_out);
1133 for (
y = 0;
y <
h; ++
y)
1135 src_f = (
const float *)(
src +
y * pitch_in);
1136 dst_s = (
unsigned short *) (
dst +
y * pitch_out);
1137 for (
x = 0;
x <
w; ++
x)
1145 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1147 static const unsigned char convert_5to8[] =
1149 0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
1150 0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
1151 0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
1152 0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
1154 static const unsigned char convert_6to8[] =
1156 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
1157 0x20, 0x24, 0x28, 0x2d, 0x31, 0x35, 0x39, 0x3d,
1158 0x41, 0x45, 0x49, 0x4d, 0x51, 0x55, 0x59, 0x5d,
1159 0x61, 0x65, 0x69, 0x6d, 0x71, 0x75, 0x79, 0x7d,
1160 0x82, 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e,
1161 0xa2, 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe,
1162 0xc2, 0xc6, 0xca, 0xce, 0xd2, 0xd7, 0xdb, 0xdf,
1163 0xe3, 0xe7, 0xeb, 0xef, 0xf3, 0xf7, 0xfb, 0xff,
1167 TRACE(
"Converting %ux%u pixels, pitches %u %u.\n",
w,
h, pitch_in, pitch_out);
1169 for (
y = 0;
y <
h; ++
y)
1171 const WORD *src_line = (
const WORD *)(
src +
y * pitch_in);
1173 for (
x = 0;
x <
w; ++
x)
1175 WORD pixel = src_line[
x];
1176 dst_line[
x] = 0xff000000u
1177 | convert_5to8[(pixel & 0xf800u) >> 11] << 16
1178 | convert_6to8[(pixel & 0x07e0u) >> 5] << 8
1179 | convert_5to8[(pixel & 0x001fu)];
1187 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1191 TRACE(
"Converting %ux%u pixels, pitches %u %u.\n",
w,
h, pitch_in, pitch_out);
1193 for (
y = 0;
y <
h; ++
y)
1198 for (
x = 0;
x <
w; ++
x)
1200 dst_line[
x] = 0xff000000 | (src_line[
x] & 0xffffff);
1207 return (
BYTE)((
x < 0) ? 0 : ((
x > 255) ? 255 :
x));
1211 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1213 int c2,
d,
e,
r2 = 0, g2 = 0,
b2 = 0;
1216 TRACE(
"Converting %ux%u pixels, pitches %u %u.\n",
w,
h, pitch_in, pitch_out);
1218 for (
y = 0;
y <
h; ++
y)
1220 const BYTE *src_line =
src +
y * pitch_in;
1222 for (
x = 0;
x <
w; ++
x)
1233 d = (
int) src_line[1] - 128;
1234 e = (
int) src_line[3] - 128;
1236 g2 = - 100 *
d - 208 *
e + 128;
1239 c2 = 298 * ((
int) src_line[0] - 16);
1240 dst_line[
x] = 0xff000000
1253 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1256 int c2,
d,
e,
r2 = 0, g2 = 0,
b2 = 0;
1258 TRACE(
"Converting %ux%u pixels, pitches %u %u\n",
w,
h, pitch_in, pitch_out);
1260 for (
y = 0;
y <
h; ++
y)
1262 const BYTE *src_line =
src +
y * pitch_in;
1264 for (
x = 0;
x <
w; ++
x)
1275 d = (
int) src_line[1] - 128;
1276 e = (
int) src_line[3] - 128;
1278 g2 = - 100 *
d - 208 *
e + 128;
1281 c2 = 298 * ((
int) src_line[0] - 16);
1294 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1300 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1306 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1312 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1318 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1324 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1330 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1336 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1342 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1348 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1354 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1360 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1366 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1372 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1378 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1384 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1390 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1396 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1402 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1408 DWORD pitch_in,
DWORD pitch_out,
unsigned int w,
unsigned int h)
1479 unsigned int texture_level = sub_resource_idx % src_texture->
level_count;
1484 unsigned int src_row_pitch, src_slice_pitch;
1496 FIXME(
"Cannot find a conversion function from format %s to %s.\n",
1505 desc.multisample_quality = 0;
1516 ERR(
"Failed to create a destination texture for conversion.\n");
1520 if (
device->d3d_initialized)
1526 map_binding = src_texture->
resource.map_binding;
1534 unsigned int dst_row_pitch, dst_slice_pitch;
1539 map_binding = dst_texture->
resource.map_binding;
1559 POINT dst_point = {0, 0};
1561 TRACE(
"Using upload conversion.\n");
1587 unsigned int row_pitch, slice_pitch;
1591 BOOL src_is_upside_down;
1598 if (restore_rt != surface)
1604 if (src_location !=
texture->resource.draw_binding)
1623 TRACE(
"Mapping offscreen render target.\n");
1625 src_is_upside_down =
TRUE;
1633 src_is_upside_down =
FALSE;
1637 if (
data.buffer_object)
1653 texture->resource.format->glFormat,
1661 if (!src_is_upside_down)
1669 if (
data.buffer_object)
1689 if (
data.buffer_object)
1694 if (
data.buffer_object)
1722 if (restore_rt != surface)
1733 TRACE(
"Reading back offscreen render target %p.\n", surface);
1762 unsigned int src_height, src_level, dst_level;
1767 RECT dst_rect = *dst_rect_in;
1789 TRACE(
"Reading from an offscreen target\n");
1790 upsidedown = !upsidedown;
1802 if ((xrel - 1.0f < -
eps) || (xrel - 1.0f >
eps))
1804 FIXME_(d3d_perf)(
"Doing a pixel by pixel copy from the framebuffer to a texture.\n");
1807 ERR(
"Texture filtering not supported in direct blit.\n");
1810 && ((yrel - 1.0f < -
eps) || (yrel - 1.0f >
eps)))
1812 ERR(
"Texture filtering not supported in direct blit\n");
1815 src_level = src_sub_resource_idx % src_texture->
level_count;
1816 dst_level = dst_sub_resource_idx % dst_texture->
level_count;
1821 && !((xrel - 1.0f < -
eps) || (xrel - 1.0f >
eps))
1822 && !((yrel - 1.0f < -
eps) || (yrel - 1.0f >
eps)))
1825 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(dst_target, dst_level,
1826 dst_rect.
left , dst_rect.
top ,
1827 src_rect->
left, src_height - src_rect->
bottom,
1841 if ((xrel - 1.0f < -
eps) || (xrel - 1.0f >
eps))
1848 for (col = dst_rect.
left; col < dst_rect.
right; ++col)
1850 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(dst_target, dst_level,
1852 src_rect->
left + col * xrel,
yoffset - (
int) (
row * yrel), 1, 1);
1857 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(dst_target, dst_level,
1877 unsigned int src_width, src_height, src_pow2_width, src_pow2_height, src_level;
1883 GLenum src_target, dst_target, texture_target;
1890 BOOL noBackBufferBackup;
1893 RECT dst_rect = *dst_rect_in;
1895 TRACE(
"Using hwstretch blit\n");
1907 src_level = src_sub_resource_idx % src_texture->
level_count;
1915 if (!noBackBufferBackup && !src_texture->texture_rgb.name)
1924 if (
context->aux_buffers >= 2)
1929 else if ((!src_offscreen || offscreen_buffer ==
GL_BACK) &&
context->aux_buffers >= 1)
1935 if (noBackBufferBackup)
1947 texture_target = src_target;
1949 gl_info->gl_ops.gl.p_glEnable(texture_target);
1968 TRACE(
"Reading from an offscreen target\n");
1969 upsidedown = !upsidedown;
1970 gl_info->gl_ops.gl.p_glReadBuffer(offscreen_buffer);
1978 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(texture_target, 0, 0, 0, 0, 0, src_width, src_height);
1989 if (!src_texture->
swapchain || src_texture == src_texture->
swapchain->back_buffers[0])
2020 gl_info->gl_ops.gl.p_glDisable(texture_target);
2032 top = src_height - src_rect->
top;
2043 left /= src_pow2_width;
2044 right /= src_pow2_width;
2045 top /= src_pow2_height;
2046 bottom /= src_pow2_height;
2054 gl_info->gl_ops.gl.p_glReadBuffer(drawBuffer);
2059 gl_info->gl_ops.gl.p_glVertex2i(0, 0);
2075 if (texture_target != dst_target)
2077 gl_info->gl_ops.gl.p_glDisable(texture_target);
2078 gl_info->gl_ops.gl.p_glEnable(dst_target);
2079 texture_target = dst_target;
2084 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(texture_target,
2098 gl_info->gl_ops.gl.p_glDisable(texture_target);
2106 if (texture_target != src_target)
2108 gl_info->gl_ops.gl.p_glDisable(texture_target);
2109 gl_info->gl_ops.gl.p_glEnable(src_target);
2110 texture_target = src_target;
2117 gl_info->gl_ops.gl.p_glTexCoord2f(0.0f, 0.0f);
2118 gl_info->gl_ops.gl.p_glVertex2i(0, src_height);
2121 gl_info->gl_ops.gl.p_glTexCoord2f(0.0f, (
float)src_height / (
float)src_pow2_height);
2122 gl_info->gl_ops.gl.p_glVertex2i(0, 0);
2125 gl_info->gl_ops.gl.p_glTexCoord2f((
float)src_width / (
float)src_pow2_width,
2126 (
float)src_height / (
float)src_pow2_height);
2127 gl_info->gl_ops.gl.p_glVertex2i(src_width, 0);
2130 gl_info->gl_ops.gl.p_glTexCoord2f((
float)src_width / (
float)src_pow2_width, 0.0f);
2131 gl_info->gl_ops.gl.p_glVertex2i(src_width, src_height);
2134 gl_info->gl_ops.gl.p_glDisable(texture_target);
2138 if (
src != src_texture->texture_rgb.name &&
src !=
backup)
2140 gl_info->gl_ops.gl.p_glDeleteTextures(1, &
src);
2150 gl_info->gl_ops.gl.p_glFlush();
2168 UINT drawable_height;
2181 drawable_height = windowsize.
bottom - windowsize.
top;
2183 rect->top = drawable_height -
rect->top;
2184 rect->bottom = drawable_height -
rect->bottom;
2197 TRACE(
"dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
2204 WARN(
"Destination resource is not GPU accessible, rejecting GL blit.\n");
2215 WARN(
"Source resource is not GPU accessible, rejecting GL blit.\n");
2224 src_swapchain =
NULL;
2228 if (!dst_swapchain && !src_swapchain && src_surface != rt && dst_surface != rt)
2230 TRACE(
"No surface is render target, not using hardware blit.\n");
2238 TRACE(
"Destination color key not supported in accelerated Blit, falling back to software\n");
2242 if (dst_swapchain && dst_swapchain == src_swapchain)
2244 FIXME(
"Implement hardware blit between two surfaces on the same swapchain\n");
2248 if (dst_swapchain && src_swapchain)
2250 FIXME(
"Implement hardware blit between two different swapchains\n");
2257 if (src_surface == rt)
2258 TRACE(
"Blit from active render target to a swapchain\n");
2260 else if (src_swapchain && dst_surface == rt)
2262 FIXME(
"Implement blit from a swapchain to the active render target\n");
2266 if ((src_swapchain || src_surface == rt) && !dst_swapchain)
2268 unsigned int src_level, src_width, src_height;
2276 TRACE(
"P8 read back not supported by frame buffer to texture blit\n");
2282 TRACE(
"Color keying not supported by frame buffer to texture blit\n");
2305 if (!stretchx || dst_rect->
right - dst_rect->
left > src_width
2306 || dst_rect->
bottom - dst_rect->
top > src_height)
2308 TRACE(
"No stretching in x direction, using direct framebuffer -> texture copy.\n");
2313 TRACE(
"Using hardware stretching to flip / stretch the texture.\n");
2321 TRACE(
"Didn't find any usable render target setup for hw blit, falling back to software\n");
2332 struct wined3d_texture_sub_resource *sub_resource;
2334 sub_resource = &
texture->sub_resources[sub_resource_idx];
2368 FIXME(
"Can't load surface %p with location flags %s into sysmem.\n",
2387 FIXME(
"Unimplemented copy from %s for depth/stencil buffers.\n",
2395 ERR(
"Trying to load offscreen surface into WINED3D_LOCATION_DRAWABLE.\n");
2401 if (restore_rt != surface)
2424 unsigned int width,
height,
level, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch;
2430 struct wined3d_texture_sub_resource *sub_resource;
2434 POINT dst_point = {0, 0};
2479 &
texture->resource, src_location, &
texture->resource, dst_location))
2481 &src_rect, surface, dst_location, &src_rect);
2493 FIXME_(d3d_perf)(
"Downloading RGB surface %p to reload it as sRGB.\n", surface);
2502 FIXME_(d3d_perf)(
"Downloading sRGB surface %p to reload it as RGB.\n", surface);
2509 WARN(
"Trying to load a texture from sysmem, but no simple location is valid.\n");
2525#if !defined(STAGING_CSMT)
2526 if ((
format.conv_byte_count || conversion) &&
texture->sub_resources[sub_resource_idx].buffer_object)
2528 if ((
format.conv_byte_count || conversion) &&
texture->sub_resources[sub_resource_idx].buffer)
2531 TRACE(
"Removing the pbo attached to surface %p.\n", surface);
2538 if (
format.conv_byte_count)
2546 if (!(dst_mem =
heap_alloc(dst_slice_pitch)))
2548 ERR(
"Out of memory (%u).\n", dst_slice_pitch);
2552 format.upload(src_mem, dst_mem, src_row_pitch, src_slice_pitch,
2553 dst_row_pitch, dst_slice_pitch,
width,
height, 1);
2554 src_row_pitch = dst_row_pitch;
2557 data.buffer_object = 0;
2558 data.addr = dst_mem;
2560 else if (conversion)
2570 if (!(dst_mem =
heap_alloc(dst_slice_pitch)))
2572 ERR(
"Out of memory (%u).\n", dst_slice_pitch);
2578 conversion->
convert(src_mem, src_row_pitch, dst_mem, dst_row_pitch,
2580 src_row_pitch = dst_row_pitch;
2583 data.buffer_object = 0;
2584 data.addr = dst_mem;
2609 FIXME(
"Unimplemented copy from %s for depth/stencil buffers.\n",
2624 surface, src_location, &
rect, surface, dst_location, &
rect);
2654 ERR(
"Don't know how to handle location %#x.\n",
location);
2671 unsigned int rt_count,
const struct wined3d_fb_state *fb,
unsigned int rect_count,
const RECT *clear_rects,
2701 src_resource, src_location, dst_resource, dst_location))
2705 src_rect, dst_surface, dst_location, dst_rect, colour_key,
filter);
2710 TRACE(
"Colour blit.\n");
2712 src_rect, dst_surface, dst_location, dst_rect);
2713 return dst_location;
2718 TRACE(
"Depth/stencil blit.\n");
2720 return dst_location;
2723 ERR(
"This blitter does not implement blit op %#x.\n", blit_op);
2724 return dst_location;
2741 if (!(blitter =
heap_alloc(
sizeof(*blitter))))
2744 TRACE(
"Created blitter %p.\n", blitter);
2764 unsigned int rt_count,
const struct wined3d_fb_state *fb,
unsigned int rect_count,
const RECT *clear_rects,
2771 ERR(
"No blitter to handle clear.\n");
2775 TRACE(
"Forwarding to blitter %p.\n",
next);
2787 unsigned int src_sub_resource_idx, dst_sub_resource_idx;
2788 unsigned int src_level, src_layer, dst_level, dst_layer;
2791 GLuint src_name, dst_name;
2807 ERR(
"No blitter to handle blit op %#x.\n",
op);
2808 return dst_location;
2811 TRACE(
"Forwarding to blitter %p.\n",
next);
2813 src_rect, dst_surface, dst_location, dst_rect, colour_key,
filter);
2816 TRACE(
"Blit using ARB_copy_image.\n");
2819 src_level = src_sub_resource_idx % src_texture->
level_count;
2820 src_layer = src_sub_resource_idx / src_texture->
level_count;
2823 dst_level = dst_sub_resource_idx % dst_texture->
level_count;
2824 dst_layer = dst_sub_resource_idx / dst_texture->
level_count;
2851 src_rect->
left, src_rect->
top, src_layer, dst_name, dst_texture->
target, dst_level,
2852 dst_rect->
left, dst_rect->
top, dst_layer, src_rect->
right - src_rect->
left,
2878 if (!(blitter =
heap_alloc(
sizeof(*blitter))))
2881 TRACE(
"Created blitter %p.\n", blitter);
2911 TRACE(
"Source or destination resource is not GPU accessible.\n");
2926 if (
context->d3d_info->shader_color_key)
2928 TRACE(
"Color keying requires converted textures.\n");
2938 TRACE(
"Checking support for fixup:\n");
2949 WARN(
"Claiming fixup support because of ORM_BACKBUFFER.\n");
2953 TRACE(
"Fixups are not supported.\n");
2960 TRACE(
"Can only blit to render targets.\n");
2966 TRACE(
"Unsupported blit operation %#x.\n", blit_op);
2992 unsigned int rt_count,
const struct wined3d_fb_state *fb,
unsigned int rect_count,
const RECT *clear_rects,
2997 DWORD next_flags = 0;
3002 for (
i = 0;
i < rt_count; ++
i)
3013 flags &= ~WINED3DCLEAR_TARGET;
3035 if (next_flags && (
next = blitter->
next))
3037 clear_rects, draw_rect, next_flags, colour,
depth,
stencil);
3053 DWORD old_color_key_flags;
3056 src_resource = &src_texture->
resource;
3057 dst_resource = &dst_texture->
resource;
3067 TRACE(
"Blt from surface %p to rendertarget %p\n", src_surface, dst_surface);
3069 old_blt_key = src_texture->
async.src_blt_color_key;
3070 old_color_key_flags = src_texture->
async.color_key_flags;
3094 TRACE(
"Destination surface %p is onscreen.\n", dst_surface);
3099 TRACE(
"Destination surface %p is offscreen.\n", dst_surface);
3124 (
float)src_texture->
async.src_blt_color_key.color_space_low_value / 255.0f);
3144 checkGLcall(
"glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3149 checkGLcall(
"glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3154 gl_info->
gl_ops.gl.p_glFlush();
3160 return dst_location;
3174 if (!(blitter =
heap_alloc(
sizeof(*blitter))))
3177 TRACE(
"Created blitter %p.\n", blitter);
3199 UINT row_block_count;
3200 const BYTE *src_row;
3207 row_block_count = (update_w +
format->block_width - 1) /
format->block_width;
3211 for (
y = 0;
y < update_h;
y +=
format->block_height)
3213 memcpy(dst_row, src_row, row_block_count *
format->block_byte_count);
3214 src_row += src_pitch;
3215 dst_row += dst_pitch;
3223 src_row += (((update_h /
format->block_height) - 1) * src_pitch);
3228 for (
y = 0;
y < update_h;
y +=
format->block_height)
3233 BYTE control_row[4];
3236 const struct block *
s = (
const struct block *)src_row;
3239 for (
x = 0;
x < row_block_count; ++
x)
3241 d[
x].color[0] =
s[
x].color[0];
3242 d[
x].color[1] =
s[
x].color[1];
3243 d[
x].control_row[0] =
s[
x].control_row[3];
3244 d[
x].control_row[1] =
s[
x].control_row[2];
3245 d[
x].control_row[2] =
s[
x].control_row[1];
3246 d[
x].control_row[3] =
s[
x].control_row[0];
3248 src_row -= src_pitch;
3249 dst_row += dst_pitch;
3255 for (
y = 0;
y < update_h;
y +=
format->block_height)
3261 BYTE control_row[4];
3264 const struct block *
s = (
const struct block *)src_row;
3267 for (
x = 0;
x < row_block_count; ++
x)
3269 d[
x].alpha_row[0] =
s[
x].alpha_row[3];
3270 d[
x].alpha_row[1] =
s[
x].alpha_row[2];
3271 d[
x].alpha_row[2] =
s[
x].alpha_row[1];
3272 d[
x].alpha_row[3] =
s[
x].alpha_row[0];
3273 d[
x].color[0] =
s[
x].color[0];
3274 d[
x].color[1] =
s[
x].color[1];
3275 d[
x].control_row[0] =
s[
x].control_row[3];
3276 d[
x].control_row[1] =
s[
x].control_row[2];
3277 d[
x].control_row[2] =
s[
x].control_row[1];
3278 d[
x].control_row[3] =
s[
x].control_row[0];
3280 src_row -= src_pitch;
3281 dst_row += dst_pitch;
3286 FIXME(
"Compressed flip not implemented for format %s.\n",
3292 FIXME(
"Unsupported blit on compressed surface (format %s, flags %#x, DDFX %#x).\n",
3303 unsigned int bpp, src_height, src_width, dst_height, dst_width, row_byte_count;
3308 unsigned int src_fmt_flags, dst_fmt_flags;
3311 unsigned int x, sx, xinc,
y, sy, yinc;
3312 unsigned int texture_level;
3314 BOOL same_sub_resource;
3320 TRACE(
"dst_texture %p, dst_sub_resource_idx %u, dst_box %s, src_texture %p, "
3321 "src_sub_resource_idx %u, src_box %s, flags %#x, fx %p, filter %s.\n",
3322 dst_texture, dst_sub_resource_idx,
debug_box(dst_box), src_texture,
3325 if (
device->d3d_initialized)
3328 if (src_texture == dst_texture && src_sub_resource_idx == dst_sub_resource_idx)
3330 same_sub_resource =
TRUE;
3332 map_binding = dst_texture->
resource.map_binding;
3333 texture_level = dst_sub_resource_idx % dst_texture->
level_count;
3344 src_format = dst_texture->
resource.format;
3346 dst_fmt_flags = dst_texture->
resource.format_flags;
3347 src_fmt_flags = dst_fmt_flags;
3351 same_sub_resource =
FALSE;
3353 dst_fmt_flags = dst_texture->
resource.format_flags;
3364 src_texture = converted_texture;
3365 src_sub_resource_idx = 0;
3367 src_format = src_texture->
resource.format;
3368 src_fmt_flags = src_texture->
resource.format_flags;
3370 map_binding = src_texture->
resource.map_binding;
3371 texture_level = src_sub_resource_idx % src_texture->
level_count;
3379 map_binding = dst_texture->
resource.map_binding;
3380 texture_level = dst_sub_resource_idx % dst_texture->
level_count;
3389 flags &= ~WINED3D_BLT_RAW;
3392 src_height = src_box->
bottom - src_box->
top;
3393 src_width = src_box->
right - src_box->
left;
3394 dst_height = dst_box->
bottom - dst_box->
top;
3395 dst_width = dst_box->
right - dst_box->
left;
3396 row_byte_count = dst_width *
bpp;
3409 if (same_sub_resource)
3411 FIXME(
"Only plain blits supported on compressed surfaces.\n");
3416 if (src_height != dst_height || src_width != dst_width)
3418 WARN(
"Stretching not supported on compressed surfaces.\n");
3430 && (src_width != dst_width || src_height != dst_height))
3437 xinc = (src_width << 16) / dst_width;
3438 yinc = (src_height << 16) / dst_height;
3443 if (dst_width == src_width)
3445 if (dst_height == src_height)
3452 if (!same_sub_resource || dst_box->
top < src_box->
top
3456 for (
y = 0;
y < dst_height; ++
y)
3458 memcpy(dbuf, sbuf, row_byte_count);
3463 else if (dst_box->
top > src_box->
top)
3468 for (
y = 0;
y < dst_height; ++
y)
3472 memcpy(dbuf, sbuf, row_byte_count);
3478 for (
y = 0;
y < dst_height; ++
y)
3480 memmove(dbuf, sbuf, row_byte_count);
3489 for (
y = sy = 0;
y < dst_height; ++
y, sy += yinc)
3491 sbuf = sbase + (sy >> 16) * src_map.
row_pitch;
3492 memcpy(dbuf, sbuf, row_byte_count);
3500 unsigned int last_sy = ~0
u;
3501 for (
y = sy = 0;
y < dst_height; ++
y, sy += yinc)
3503 sbuf = sbase + (sy >> 16) * src_map.
row_pitch;
3505 if ((sy >> 16) == (last_sy >> 16))
3513#define STRETCH_ROW(type) \
3515 const type *s = (const type *)sbuf; \
3516 type *d = (type *)dbuf; \
3517 for (x = sx = 0; x < dst_width; ++x, sx += xinc) \
3518 d[x] = s[sx >> 16]; \
3536 for (
x = sx = 0;
x < dst_width;
x++, sx+= xinc)
3540 s = sbuf + 3 * (sx >> 16);
3541 pixel =
s[0] | (
s[1] << 8) | (
s[2] << 16);
3542 d[0] = (pixel ) & 0xff;
3543 d[1] = (pixel >> 8) & 0xff;
3544 d[2] = (pixel >> 16) & 0xff;
3550 FIXME(
"Stretched blit not implemented for bpp %u.\n",
bpp * 8);
3564 DWORD keylow = 0xffffffff, keyhigh = 0, keymask = 0xffffffff;
3565 DWORD destkeylow = 0x0, destkeyhigh = 0xffffffff, destkeymask = 0xffffffff;
3572 keylow = src_texture->
async.src_blt_color_key.color_space_low_value;
3573 keyhigh = src_texture->
async.src_blt_color_key.color_space_high_value;
3577 keylow =
fx->src_color_key.color_space_low_value;
3578 keyhigh =
fx->src_color_key.color_space_high_value;
3584 destkeylow = src_texture->
async.dst_blt_color_key.color_space_low_value;
3585 destkeyhigh = src_texture->
async.dst_blt_color_key.color_space_high_value;
3589 destkeylow =
fx->dst_color_key.color_space_low_value;
3590 destkeyhigh =
fx->dst_color_key.color_space_high_value;
3609 BYTE *dTopLeft, *dTopRight, *dBottomLeft, *dBottomRight, *tmp;
3612 dTopRight = dbuf + ((dst_width - 1) *
bpp);
3613 dBottomLeft = dTopLeft + ((dst_height - 1) * dst_map.
row_pitch);
3614 dBottomRight = dBottomLeft + ((dst_width - 1) *
bpp);
3619 WARN(
"Nothing done for WINEDDBLTFX_ARITHSTRETCHY.\n");
3624 dTopRight = dTopLeft;
3627 dBottomRight = dBottomLeft;
3629 dstxinc = dstxinc * -1;
3634 dTopLeft = dBottomLeft;
3637 dTopRight = dBottomRight;
3639 dstyinc = dstyinc * -1;
3644 WARN(
"Nothing done for WINEDDBLTFX_NOTEARING.\n");
3649 dBottomRight = dTopLeft;
3652 dBottomLeft = dTopRight;
3654 dstxinc = dstxinc * -1;
3655 dstyinc = dstyinc * -1;
3660 dTopLeft = dBottomLeft;
3661 dBottomLeft = dBottomRight;
3662 dBottomRight = dTopRight;
3667 dstxinc = dstxinc * -1;
3672 dTopLeft = dTopRight;
3673 dTopRight = dBottomRight;
3674 dBottomRight = dBottomLeft;
3679 dstyinc = dstyinc * -1;
3684 WARN(
"Nothing done for WINEDDBLTFX_ZBUFFERBASEDEST.\n");
3690#define COPY_COLORKEY_FX(type) \
3693 type *d = (type *)dbuf, *dx, tmp; \
3694 for (y = sy = 0; y < dst_height; ++y, sy += yinc) \
3696 s = (const type *)(sbase + (sy >> 16) * src_map.row_pitch); \
3698 for (x = sx = 0; x < dst_width; ++x, sx += xinc) \
3700 tmp = s[sx >> 16]; \
3701 if (((tmp & keymask) < keylow || (tmp & keymask) > keyhigh) \
3702 && ((dx[0] & destkeymask) >= destkeylow && (dx[0] & destkeymask) <= destkeyhigh)) \
3706 dx = (type *)(((BYTE *)dx) + dstxinc); \
3708 d = (type *)(((BYTE *)d) + dstyinc); \
3727 for (
y = sy = 0;
y < dst_height; ++
y, sy += yinc)
3729 sbuf = sbase + (sy >> 16) * src_map.
row_pitch;
3731 for (
x = sx = 0;
x < dst_width; ++
x, sx+= xinc)
3733 DWORD pixel, dpixel = 0;
3734 s = sbuf + 3 * (sx>>16);
3735 pixel =
s[0] | (
s[1] << 8) | (
s[2] << 16);
3736 dpixel =
dx[0] | (
dx[1] << 8 ) | (
dx[2] << 16);
3737 if (((pixel & keymask) < keylow || (pixel & keymask) > keyhigh)
3738 && ((dpixel & keymask) >= destkeylow || (dpixel & keymask) <= keyhigh))
3740 dx[0] = (pixel ) & 0xff;
3741 dx[1] = (pixel >> 8) & 0xff;
3742 dx[2] = (pixel >> 16) & 0xff;
3751 FIXME(
"%s color-keyed blit not implemented for bpp %u.\n",
3755#undef COPY_COLORKEY_FX
3765 if (!same_sub_resource)
3770 dst_box->
left, dst_box