[D3D9][WINED3D] Sync with Wine 3.0. CORE-14225

This commit is contained in:
Amine Khaldi 2018-01-21 22:20:57 +01:00
parent d255223474
commit d6ac0a71ad
34 changed files with 10600 additions and 12121 deletions

View file

@ -37,7 +37,6 @@
#define COBJMACROS
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <wine/debug.h>
@ -104,6 +103,8 @@ struct d3d9_device
BOOL in_scene;
BOOL has_vertex_declaration;
unsigned int max_user_clip_planes;
UINT implicit_swapchain_count;
struct d3d9_swapchain **implicit_swapchains;
};

View file

@ -22,6 +22,8 @@
#include "d3d9_private.h"
#include <winuser.h>
static void STDMETHODCALLTYPE d3d9_null_wined3d_object_destroyed(void *parent) {}
const struct wined3d_parent_ops d3d9_null_wined3d_parent_ops =
@ -236,8 +238,6 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch
= wined3dformat_from_d3dformat(present_parameters->AutoDepthStencilFormat);
swapchain_desc->flags
= (present_parameters->Flags & D3DPRESENTFLAGS_MASK) | WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH;
if (is_gdi_compat_wined3dformat(swapchain_desc->backbuffer_format))
swapchain_desc->flags |= WINED3D_SWAPCHAIN_GDI_COMPATIBLE;
swapchain_desc->refresh_rate = present_parameters->FullScreen_RefreshRateInHz;
swapchain_desc->swap_interval = present_parameters->PresentationInterval;
swapchain_desc->auto_restore_display_mode = TRUE;
@ -811,11 +811,13 @@ static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device)
static HRESULT d3d9_device_reset(struct d3d9_device *device,
D3DPRESENT_PARAMETERS *present_parameters, D3DDISPLAYMODEEX *mode)
{
BOOL extended = device->d3d_parent->extended;
struct wined3d_swapchain_desc swapchain_desc;
struct wined3d_display_mode wined3d_mode;
HRESULT hr;
if (!device->d3d_parent->extended && device->device_state == D3D9_DEVICE_STATE_LOST)
if (!extended && device->device_state == D3D9_DEVICE_STATE_LOST)
{
WARN("App not active, returning D3DERR_DEVICELOST.\n");
return D3DERR_DEVICELOST;
@ -830,8 +832,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
wined3d_mode.scanline_ordering = mode->ScanLineOrdering;
}
if (!wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters,
device->d3d_parent->extended))
if (!wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters, extended))
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
@ -851,10 +852,16 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
}
if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc,
mode ? &wined3d_mode : NULL, reset_enum_callback, !device->d3d_parent->extended)))
mode ? &wined3d_mode : NULL, reset_enum_callback, !extended)))
{
HeapFree(GetProcessHeap(), 0, device->implicit_swapchains);
if (!extended)
{
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE,
!!swapchain_desc.enable_auto_depth_stencil);
}
if (FAILED(hr = d3d9_device_get_swapchains(device)))
{
device->device_state = D3D9_DEVICE_STATE_NOT_RESET;
@ -870,7 +877,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
device->device_state = D3D9_DEVICE_STATE_OK;
}
}
else if (!device->d3d_parent->extended)
else if (!extended)
{
device->device_state = D3D9_DEVICE_STATE_NOT_RESET;
}
@ -1392,20 +1399,35 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface,
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct d3d9_surface *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
struct wined3d_sub_resource_desc src_desc, dst_desc;
struct wined3d_box src_box;
HRESULT hr;
TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
iface, src_surface, src_rect, dst_surface, dst_point);
wined3d_mutex_lock();
wined3d_texture_get_sub_resource_desc(src->wined3d_texture, src->sub_resource_idx, &src_desc);
wined3d_texture_get_sub_resource_desc(dst->wined3d_texture, dst->sub_resource_idx, &dst_desc);
if (src_desc.format != dst_desc.format)
{
wined3d_mutex_unlock();
WARN("Surface formats (%#x/%#x) don't match.\n",
d3dformat_from_wined3dformat(src_desc.format),
d3dformat_from_wined3dformat(dst_desc.format));
return D3DERR_INVALIDCALL;
}
if (src_rect)
wined3d_box_set(&src_box, src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1);
else
wined3d_box_set(&src_box, 0, 0, src_desc.width, src_desc.height, 0, 1);
wined3d_mutex_lock();
hr = wined3d_device_copy_sub_resource_region(device->wined3d_device,
wined3d_texture_get_resource(dst->wined3d_texture), dst->sub_resource_idx, dst_point ? dst_point->x : 0,
dst_point ? dst_point->y : 0, 0, wined3d_texture_get_resource(src->wined3d_texture),
src->sub_resource_idx, src_rect ? &src_box : NULL);
src->sub_resource_idx, &src_box);
wined3d_mutex_unlock();
if (FAILED(hr))
@ -2014,6 +2036,8 @@ static HRESULT WINAPI d3d9_device_SetClipPlane(IDirect3DDevice9Ex *iface, DWORD
TRACE("iface %p, index %u, plane %p.\n", iface, index, plane);
index = min(index, device->max_user_clip_planes - 1);
wined3d_mutex_lock();
hr = wined3d_device_set_clip_plane(device->wined3d_device, index, (const struct wined3d_vec4 *)plane);
wined3d_mutex_unlock();
@ -2028,6 +2052,8 @@ static HRESULT WINAPI d3d9_device_GetClipPlane(IDirect3DDevice9Ex *iface, DWORD
TRACE("iface %p, index %u, plane %p.\n", iface, index, plane);
index = min(index, device->max_user_clip_planes - 1);
wined3d_mutex_lock();
hr = wined3d_device_get_clip_plane(device->wined3d_device, index, (struct wined3d_vec4 *)plane);
wined3d_mutex_unlock();
@ -3547,9 +3573,12 @@ static HRESULT WINAPI d3d9_device_CheckResourceResidency(IDirect3DDevice9Ex *ifa
static HRESULT WINAPI d3d9_device_SetMaximumFrameLatency(IDirect3DDevice9Ex *iface, UINT max_latency)
{
FIXME("iface %p, max_latency %u stub!\n", iface, max_latency);
TRACE("iface %p, max_latency %u.\n", iface, max_latency);
return E_NOTIMPL;
if (max_latency)
FIXME("Ignoring max_latency %u.\n", max_latency);
return S_OK;
}
static HRESULT WINAPI d3d9_device_GetMaximumFrameLatency(IDirect3DDevice9Ex *iface, UINT *max_latency)
@ -3919,6 +3948,9 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic
if (container_parent == device_parent)
container_parent = &device->IDirect3DDevice9Ex_iface;
if (is_gdi_compat_wined3dformat(desc->format))
texture_flags |= WINED3D_TEXTURE_CREATE_GET_DC;
if (FAILED(hr = wined3d_texture_create(device->wined3d_device, desc, 1, 1,
texture_flags | WINED3D_TEXTURE_CREATE_MAPPABLE, NULL, container_parent,
&d3d9_null_wined3d_parent_ops, texture)))
@ -3990,7 +4022,8 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode)
{
struct wined3d_swapchain_desc *swapchain_desc;
UINT i, count = 1;
unsigned i, count = 1;
WINED3DCAPS caps;
HRESULT hr;
if (mode)
@ -4003,22 +4036,18 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock();
hr = wined3d_device_create(wined3d, adapter, device_type, focus_window, flags, 4,
&device->device_parent, &device->wined3d_device);
if (FAILED(hr))
if (FAILED(hr = wined3d_device_create(wined3d, adapter, device_type, focus_window, flags, 4,
&device->device_parent, &device->wined3d_device)))
{
WARN("Failed to create wined3d device, hr %#x.\n", hr);
wined3d_mutex_unlock();
return hr;
}
wined3d_get_device_caps(wined3d, adapter, device_type, &caps);
device->max_user_clip_planes = caps.MaxUserClipPlanes;
if (flags & D3DCREATE_ADAPTERGROUP_DEVICE)
{
WINED3DCAPS caps;
wined3d_get_device_caps(wined3d, adapter, device_type, &caps);
count = caps.NumberOfAdaptersInGroup;
}
if (flags & D3DCREATE_MULTITHREADED)
wined3d_device_set_multithreaded(device->wined3d_device);
@ -4069,8 +4098,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
}
}
hr = wined3d_device_init_3d(device->wined3d_device, swapchain_desc);
if (FAILED(hr))
if (FAILED(hr = wined3d_device_init_3d(device->wined3d_device, swapchain_desc)))
{
WARN("Failed to initialize 3D, hr %#x.\n", hr);
wined3d_device_release_focus_window(device->wined3d_device);
@ -4080,6 +4108,9 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
return hr;
}
wined3d_device_set_render_state(device->wined3d_device,
WINED3D_RS_ZENABLE, !!swapchain_desc->enable_auto_depth_stencil);
if (FAILED(hr = d3d9_device_get_swapchains(device)))
{
wined3d_device_uninit_3d(device->wined3d_device);

View file

@ -577,7 +577,8 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
{
DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
| WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR
| WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT;
| WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING
| WINED3D_NORMALIZED_DEPTH_BIAS;
if (!extended)
flags |= WINED3D_VIDMEM_ACCOUNTING;

View file

@ -184,7 +184,11 @@ HRESULT query_init(struct d3d9_query *query, struct d3d9_device *device, D3DQUER
if (type > D3DQUERYTYPE_MEMORYPRESSURE)
{
WARN("Invalid query type %#x.\n", type);
if (type == 0x16)
FIXME("Undocumented query %#x created.\n", type);
else
WARN("Invalid query type %#x.\n", type);
return D3DERR_NOTAVAILABLE;
}

View file

@ -22,17 +22,17 @@
static inline struct d3d9_texture *impl_from_IDirect3DTexture9(IDirect3DTexture9 *iface)
{
return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
}
static inline struct d3d9_texture *impl_from_IDirect3DCubeTexture9(IDirect3DCubeTexture9 *iface)
{
return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
}
static inline struct d3d9_texture *impl_from_IDirect3DVolumeTexture9(IDirect3DVolumeTexture9 *iface)
{
return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
}
static HRESULT WINAPI d3d9_texture_2d_QueryInterface(IDirect3DTexture9 *iface, REFIID riid, void **out)
@ -270,13 +270,7 @@ static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_2d_GetAutoGenFilterType(IDirect3
static void WINAPI d3d9_texture_2d_GenerateMipSubLevels(IDirect3DTexture9 *iface)
{
struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
wined3d_texture_generate_mipmaps(texture->wined3d_texture);
wined3d_mutex_unlock();
}
static HRESULT WINAPI d3d9_texture_2d_GetLevelDesc(IDirect3DTexture9 *iface, UINT level, D3DSURFACE_DESC *desc)
@ -655,13 +649,7 @@ static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_cube_GetAutoGenFilterType(IDirec
static void WINAPI d3d9_texture_cube_GenerateMipSubLevels(IDirect3DCubeTexture9 *iface)
{
struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
wined3d_texture_generate_mipmaps(texture->wined3d_texture);
wined3d_mutex_unlock();
}
static HRESULT WINAPI d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *iface, UINT level, D3DSURFACE_DESC *desc)
@ -1052,13 +1040,7 @@ static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_3d_GetAutoGenFilterType(IDirect3
static void WINAPI d3d9_texture_3d_GenerateMipSubLevels(IDirect3DVolumeTexture9 *iface)
{
struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
wined3d_texture_generate_mipmaps(texture->wined3d_texture);
wined3d_mutex_unlock();
}
static HRESULT WINAPI d3d9_texture_3d_GetLevelDesc(IDirect3DVolumeTexture9 *iface, UINT level, D3DVOLUME_DESC *desc)

View file

@ -872,7 +872,7 @@ static void shader_generate_arb_declarations(const struct wined3d_shader *shader
/* After subtracting privately used constants from the hardware limit(they are loaded as
* local constants), make sure the shader doesn't violate the env constant limit
*/
if(pshader)
if (pshader)
{
max_constantsF = min(max_constantsF, gl_info->limits.arb_ps_float_constants);
}
@ -900,10 +900,7 @@ static void shader_generate_arb_declarations(const struct wined3d_shader *shader
{
for (i = 0; i < max_constantsF; ++i)
{
DWORD idx, mask;
idx = i >> 5;
mask = 1u << (i & 0x1fu);
if (!shader_constant_is_local(shader, i) && (reg_maps->constf[idx] & mask))
if (!shader_constant_is_local(shader, i) && wined3d_extract_bits(reg_maps->constf, i, 1))
{
shader_addline(buffer, "PARAM C%d = program.env[%d];\n",i, i);
}
@ -1188,8 +1185,6 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
sprintf(register_name, "%s", rastout_reg_names[reg->idx[0].offset]);
break;
case WINED3DSPR_DEPTHOUT_GREATER_EQUAL:
case WINED3DSPR_DEPTHOUT_LESS_EQUAL:
case WINED3DSPR_DEPTHOUT:
strcpy(register_name, "result.depth");
break;
@ -4490,7 +4485,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
int i;
WORD int_skip;
find_vs_compile_args(state, shader, context->stream_info.swizzle_map, &args->super, d3d_info);
find_vs_compile_args(state, shader, context->stream_info.swizzle_map, &args->super, context);
args->clip.boolclip_compare = 0;
if (use_ps(state))
@ -5089,6 +5084,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_DSY */ shader_hw_dsy,
/* WINED3DSIH_DSY_COARSE */ NULL,
/* WINED3DSIH_DSY_FINE */ NULL,
/* WINED3DSIH_EVAL_SAMPLE_INDEX */ NULL,
/* WINED3DSIH_ELSE */ shader_hw_else,
/* WINED3DSIH_EMIT */ NULL,
/* WINED3DSIH_EMIT_STREAM */ NULL,
@ -7705,6 +7701,14 @@ static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info,
if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
return FALSE;
if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_format->id == src_format->id)
{
if (dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
blit_op = WINED3D_BLIT_OP_DEPTH_BLIT;
else
blit_op = WINED3D_BLIT_OP_COLOR_BLIT;
}
switch (blit_op)
{
case WINED3D_BLIT_OP_COLOR_BLIT_CKEY:
@ -7778,7 +7782,7 @@ static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info,
}
}
static void arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
@ -7796,9 +7800,8 @@ static void arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli
dst_texture->resource.pool, dst_texture->resource.format, dst_location))
{
if ((next = blitter->next))
next->ops->blitter_blit(next, op, context, src_surface, src_location,
return next->ops->blitter_blit(next, op, context, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect, color_key, filter);
return;
}
arbfp_blitter = CONTAINING_RECORD(blitter, struct wined3d_arbfp_blitter, blitter);
@ -7873,6 +7876,8 @@ static void arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli
if (wined3d_settings.strict_draw_ordering
|| (dst_texture->swapchain && (dst_texture->swapchain->front_buffer == dst_texture)))
context->gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
return dst_location;
}
static void arbfp_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device,
@ -7905,6 +7910,9 @@ void wined3d_arbfp_blitter_create(struct wined3d_blitter **next, const struct wi
if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
return;
if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
return;
if (!(blitter = HeapAlloc(GetProcessHeap(), 0, sizeof(*blitter))))
{
ERR("Failed to allocate blitter.\n");

View file

@ -529,7 +529,7 @@ ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
/* Context activation is done by the caller. */
static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context,
const void *data, unsigned int range_count, const struct wined3d_map_range *ranges)
const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_map_range *range;
@ -540,7 +540,7 @@ static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct w
{
range = &ranges[range_count];
GL_EXTCALL(glBufferSubData(buffer->buffer_type_hint,
range->offset, range->size, (BYTE *)data + range->offset));
range->offset, range->size, (BYTE *)data + range->offset - data_offset));
}
checkGLcall("glBufferSubData");
}
@ -596,7 +596,7 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined
}
}
wined3d_buffer_upload_ranges(buffer, context, data, buffer->modified_areas, buffer->maps);
wined3d_buffer_upload_ranges(buffer, context, data, 0, buffer->modified_areas, buffer->maps);
HeapFree(GetProcessHeap(), 0, data);
}
@ -680,7 +680,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
case WINED3D_LOCATION_BUFFER:
if (!buffer->conversion_map)
wined3d_buffer_upload_ranges(buffer, context, buffer->resource.heap_memory,
buffer->modified_areas, buffer->maps);
0, buffer->modified_areas, buffer->maps);
else
buffer_conversion_upload(buffer, context);
break;
@ -1212,41 +1212,23 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off
wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size);
}
HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer,
void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
const struct wined3d_box *box, const void *data)
{
UINT offset, size;
#if defined(STAGING_CSMT)
DWORD flags = 0;
#endif /* STAGING_CSMT */
HRESULT hr;
BYTE *ptr;
struct wined3d_map_range range;
if (box)
{
offset = box->left;
size = box->right - box->left;
range.offset = box->left;
range.size = box->right - box->left;
}
else
{
offset = 0;
size = buffer->resource.size;
range.offset = 0;
range.size = buffer->resource.size;
}
#if !defined(STAGING_CSMT)
if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, 0)))
#else /* STAGING_CSMT */
if (offset == 0 && size == buffer->resource.size)
flags = WINED3D_MAP_DISCARD;
if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, flags)))
#endif /* STAGING_CSMT */
return hr;
memcpy(ptr, data, size);
wined3d_buffer_unmap(buffer);
return WINED3D_OK;
wined3d_buffer_upload_ranges(buffer, context, data, range.offset, 1, &range);
}
static ULONG buffer_resource_incref(struct wined3d_resource *resource)
@ -1294,24 +1276,6 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
return wined3d_buffer_map(buffer, offset, size, (BYTE **)&map_desc->data, flags);
}
static HRESULT buffer_resource_sub_resource_map_info(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_info *info, DWORD flags)
{
struct wined3d_buffer *buffer = buffer_from_resource(resource);
if (sub_resource_idx)
{
WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
return E_INVALIDARG;
}
info->row_pitch = buffer->desc.byte_width;
info->slice_pitch = buffer->desc.byte_width;
info->size = buffer->resource.size;
return WINED3D_OK;
}
static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
if (sub_resource_idx)
@ -1331,7 +1295,6 @@ static const struct wined3d_resource_ops buffer_resource_ops =
buffer_resource_preload,
buffer_unload,
buffer_resource_sub_resource_map,
buffer_resource_sub_resource_map_info,
buffer_resource_sub_resource_unmap,
};
@ -1452,7 +1415,6 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct
struct wined3d_buffer **buffer)
{
struct wined3d_buffer *object;
enum wined3d_pool pool;
HRESULT hr;
TRACE("device %p, desc %p, data %p, parent %p, parent_ops %p, buffer %p.\n",
@ -1463,21 +1425,8 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct
FIXME("Ignoring access flags (pool).\n");
/* Some applications map the whole buffer even if they
* only update a small portion of it. If we pin such a
* buffer into system memory things get very slow as
* we upload the whole buffer even though just parts of
* it changed. Most drivers can handle this case more
* efficient using the OpenGL map functions. Applications
* affected by this problem are Banished and Witcher 3.
*/
if (desc->byte_width > 0x10000)
pool = WINED3D_POOL_DEFAULT;
else
pool = WINED3D_POOL_MANAGED;
if (FAILED(hr = buffer_init(object, device, desc->byte_width, desc->usage, WINED3DFMT_UNKNOWN,
pool, desc->bind_flags, data, parent, parent_ops)))
WINED3D_POOL_MANAGED, desc->bind_flags, data, parent, parent_ops)))
{
WARN("Failed to initialize buffer, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);

View file

@ -131,8 +131,7 @@ static void context_attach_gl_texture_fbo(struct wined3d_context *context,
gl_info->fbo_ops.glFramebufferTexture(fbo_target, attachment,
resource->object, resource->level);
}
else if (resource->target == GL_TEXTURE_1D_ARRAY || resource->target == GL_TEXTURE_2D_ARRAY ||
resource->target == GL_TEXTURE_3D)
else if (resource->target == GL_TEXTURE_2D_ARRAY || resource->target == GL_TEXTURE_3D)
{
if (!gl_info->fbo_ops.glFramebufferTextureLayer)
{
@ -143,12 +142,6 @@ static void context_attach_gl_texture_fbo(struct wined3d_context *context,
gl_info->fbo_ops.glFramebufferTextureLayer(fbo_target, attachment,
resource->object, resource->level, resource->layer);
}
else if (resource->target == GL_TEXTURE_1D)
{
gl_info->fbo_ops.glFramebufferTexture1D(fbo_target, attachment,
resource->target, resource->object, resource->level);
checkGLcall("glFramebufferTexture1D()");
}
else
{
gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment,
@ -288,7 +281,7 @@ static void context_dump_fbo_attachment(const struct wined3d_gl_info *gl_info, G
unsigned int i;
tex_type_str = NULL;
for (i = 0; i < sizeof(texture_type) / sizeof(*texture_type); ++i)
for (i = 0; i < ARRAY_SIZE(texture_type); ++i)
{
if (!gl_info->supported[texture_type[i].extension])
continue;
@ -1706,7 +1699,6 @@ void context_bind_dummy_textures(const struct wined3d_device *device, const stru
GL_EXTCALL(glActiveTexture(GL_TEXTURE0 + i));
checkGLcall("glActiveTexture");
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d);
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, device->dummy_textures.tex_2d);
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
@ -1722,10 +1714,7 @@ void context_bind_dummy_textures(const struct wined3d_device *device, const stru
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, device->dummy_textures.tex_cube_array);
if (gl_info->supported[EXT_TEXTURE_ARRAY])
{
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array);
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, device->dummy_textures.tex_2d_array);
}
if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT])
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, device->dummy_textures.tex_buffer);
@ -2326,10 +2315,13 @@ static void set_blit_dimension(const struct wined3d_gl_info *gl_info, UINT width
-1.0, -1.0, -1.0, 1.0,
};
gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode(GL_PROJECTION)");
gl_info->gl_ops.gl.p_glLoadMatrixd(projection);
checkGLcall("glLoadMatrixd");
if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
{
gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode(GL_PROJECTION)");
gl_info->gl_ops.gl.p_glLoadMatrixd(projection);
checkGLcall("glLoadMatrixd");
}
gl_info->gl_ops.gl.p_glViewport(0, 0, width, height);
checkGLcall("glViewport");
}
@ -2355,6 +2347,33 @@ static void context_get_rt_size(const struct wined3d_context *context, SIZE *siz
size->cy = wined3d_texture_get_level_height(rt, level);
}
void context_enable_clip_distances(struct wined3d_context *context, unsigned int enable_mask)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int clip_distance_count = gl_info->limits.user_clip_distances;
unsigned int i, disable_mask, current_mask;
disable_mask = ~enable_mask;
enable_mask &= (1u << clip_distance_count) - 1;
disable_mask &= (1u << clip_distance_count) - 1;
current_mask = context->clip_distance_mask;
context->clip_distance_mask = enable_mask;
enable_mask &= ~current_mask;
for (i = 0; enable_mask; enable_mask >>= 1, ++i)
{
if (enable_mask & 1)
gl_info->gl_ops.gl.p_glEnable(GL_CLIP_DISTANCE0 + i);
}
disable_mask &= current_mask;
for (i = 0; disable_mask; disable_mask >>= 1, ++i)
{
if (disable_mask & 1)
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_DISTANCE0 + i);
}
checkGLcall("toggle clip distances");
}
/*****************************************************************************
* SetupForBlit
*
@ -2374,10 +2393,10 @@ static void context_get_rt_size(const struct wined3d_context *context, SIZE *siz
/* Context activation is done by the caller. */
static void SetupForBlit(const struct wined3d_device *device, struct wined3d_context *context)
{
int i;
const struct wined3d_gl_info *gl_info = context->gl_info;
DWORD sampler;
SIZE rt_size;
int i;
TRACE("Setting up context %p for blitting\n", context);
@ -2398,17 +2417,46 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con
}
context->last_was_blit = TRUE;
/* Disable all textures. The caller can then bind a texture it wants to blit
* from
*
* The blitting code uses (for now) the fixed function pipeline, so make sure to reset all fixed
* function texture unit. No need to care for higher samplers
*/
for (i = gl_info->limits.textures - 1; i > 0 ; --i)
if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
{
sampler = context->rev_tex_unit_map[i];
context_active_texture(context, gl_info, i);
/* Disable all textures. The caller can then bind a texture it wants to blit
* from
*
* The blitting code uses (for now) the fixed function pipeline, so make sure to reset all fixed
* function texture unit. No need to care for higher samplers
*/
for (i = gl_info->limits.textures - 1; i > 0 ; --i)
{
sampler = context->rev_tex_unit_map[i];
context_active_texture(context, gl_info, i);
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB");
}
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable GL_TEXTURE_3D");
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB");
}
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable GL_TEXTURE_2D");
gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
if (sampler != WINED3D_UNMAPPED_STAGE)
{
if (sampler < MAX_TEXTURES)
context_invalidate_state(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP));
context_invalidate_state(context, STATE_SAMPLER(sampler));
}
}
context_active_texture(context, gl_info, 0);
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
@ -2425,50 +2473,43 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con
checkGLcall("glDisable GL_TEXTURE_2D");
gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
if (sampler != WINED3D_UNMAPPED_STAGE)
gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE);
checkGLcall("glMatrixMode(GL_TEXTURE)");
gl_info->gl_ops.gl.p_glLoadIdentity();
checkGLcall("glLoadIdentity()");
if (gl_info->supported[EXT_TEXTURE_LOD_BIAS])
{
if (sampler < MAX_TEXTURES)
context_invalidate_state(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP));
context_invalidate_state(context, STATE_SAMPLER(sampler));
gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
GL_TEXTURE_LOD_BIAS_EXT, 0.0f);
checkGLcall("glTexEnvf GL_TEXTURE_LOD_BIAS_EXT ...");
}
/* Setup transforms */
gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
checkGLcall("glMatrixMode(GL_MODELVIEW)");
gl_info->gl_ops.gl.p_glLoadIdentity();
checkGLcall("glLoadIdentity()");
context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
/* Other misc states */
gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST);
checkGLcall("glDisable(GL_ALPHA_TEST)");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHATESTENABLE));
gl_info->gl_ops.gl.p_glDisable(GL_LIGHTING);
checkGLcall("glDisable GL_LIGHTING");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_LIGHTING));
glDisableWINE(GL_FOG);
checkGLcall("glDisable GL_FOG");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_FOGENABLE));
}
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
GL_EXTCALL(glBindSampler(0, 0));
context_active_texture(context, gl_info, 0);
sampler = context->rev_tex_unit_map[0];
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB");
}
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable GL_TEXTURE_3D");
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB");
}
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable GL_TEXTURE_2D");
gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE);
checkGLcall("glMatrixMode(GL_TEXTURE)");
gl_info->gl_ops.gl.p_glLoadIdentity();
checkGLcall("glLoadIdentity()");
if (gl_info->supported[EXT_TEXTURE_LOD_BIAS])
{
gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
GL_TEXTURE_LOD_BIAS_EXT, 0.0f);
checkGLcall("glTexEnvf GL_TEXTURE_LOD_BIAS_EXT ...");
}
if (sampler != WINED3D_UNMAPPED_STAGE)
{
if (sampler < MAX_TEXTURES)
@ -2480,18 +2521,9 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con
}
/* Other misc states */
gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST);
checkGLcall("glDisable(GL_ALPHA_TEST)");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHATESTENABLE));
gl_info->gl_ops.gl.p_glDisable(GL_LIGHTING);
checkGLcall("glDisable GL_LIGHTING");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_LIGHTING));
gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_TEST);
checkGLcall("glDisable GL_DEPTH_TEST");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ZENABLE));
glDisableWINE(GL_FOG);
checkGLcall("glDisable GL_FOG");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_FOGENABLE));
gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
checkGLcall("glDisable GL_BLEND");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE));
@ -2512,8 +2544,10 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con
}
gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE,GL_TRUE,GL_TRUE);
checkGLcall("glColorMask");
for (i = 0; i < MAX_RENDER_TARGETS; ++i)
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITE(i)));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3));
if (gl_info->supported[EXT_SECONDARY_COLOR])
{
gl_info->gl_ops.gl.p_glDisable(GL_COLOR_SUM_EXT);
@ -2521,22 +2555,10 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con
checkGLcall("glDisable(GL_COLOR_SUM_EXT)");
}
/* Setup transforms */
gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
checkGLcall("glMatrixMode(GL_MODELVIEW)");
gl_info->gl_ops.gl.p_glLoadIdentity();
checkGLcall("glLoadIdentity()");
context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
context->last_was_rhw = TRUE;
context_invalidate_state(context, STATE_VDECL); /* because of last_was_rhw = TRUE */
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE0); checkGLcall("glDisable(clip plane 0)");
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE1); checkGLcall("glDisable(clip plane 1)");
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE2); checkGLcall("glDisable(clip plane 2)");
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE3); checkGLcall("glDisable(clip plane 3)");
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE4); checkGLcall("glDisable(clip plane 4)");
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)");
context_enable_clip_distances(context, 0);
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_CLIPPING));
/* FIXME: Make draw_textured_quad() able to work with a upper left origin. */
@ -2673,14 +2695,6 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint
case GL_NONE:
/* nothing to do */
break;
case GL_TEXTURE_1D:
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d);
checkGLcall("glBindTexture");
break;
case GL_TEXTURE_1D_ARRAY:
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array);
checkGLcall("glBindTexture");
break;
case GL_TEXTURE_2D:
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, device->dummy_textures.tex_2d);
checkGLcall("glBindTexture");
@ -3086,16 +3100,8 @@ static DWORD find_draw_buffers_mask(const struct wined3d_context *context, const
else if (!context->render_offscreen)
return context_generate_rt_mask_from_resource(rts[0]->resource);
/* If we attach more buffers than supported in dual blend mode, the NVIDIA
* driver generates the following error:
* GL_INVALID_OPERATION error generated. State(s) are invalid: blend.
* DX11 does not treat this configuration as invalid, so disable the unused ones.
*/
rt_mask = ps ? ps->reg_maps.rt_mask : 1;
if (wined3d_dualblend_enabled(state, context->gl_info))
rt_mask &= context->d3d_info->valid_dual_rt_mask;
else
rt_mask &= context->d3d_info->valid_rt_mask;
rt_mask &= context->d3d_info->valid_rt_mask;
rt_mask_bits = rt_mask;
i = 0;
while (rt_mask_bits)
@ -4008,6 +4014,16 @@ void context_apply_compute_state(struct wined3d_context *context,
context->update_unordered_access_view_bindings = 1;
}
/* Updates to currently bound render targets aren't necessarily coherent
* between the graphics and compute pipelines. Unbind any currently bound
* FBO here to ensure preceding updates to its attachments by the graphics
* pipeline are visible to the compute pipeline.
*
* Without this, the bloom effect in Nier:Automata is too bright on the
* Mesa radeonsi driver, and presumably on other Mesa based drivers. */
context_bind_fbo(context, GL_FRAMEBUFFER, 0);
context_invalidate_state(context, STATE_FRAMEBUFFER);
context->last_was_blit = FALSE;
}

View file

@ -69,7 +69,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION,
WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW,
WINED3D_CS_OP_COPY_UAV_COUNTER,
WINED3D_CS_OP_COPY_SUB_RESOURCE,
WINED3D_CS_OP_GENERATE_MIPMAPS,
WINED3D_CS_OP_STOP,
};
@ -396,9 +396,6 @@ struct wined3d_cs_update_sub_resource
unsigned int sub_resource_idx;
struct wined3d_box box;
struct wined3d_sub_resource_data data;
#if defined(STAGING_CSMT)
BYTE copy_data[1];
#endif /* STAGING_CSMT */
};
struct wined3d_cs_add_dirty_texture_region
@ -423,15 +420,10 @@ struct wined3d_cs_copy_uav_counter
struct wined3d_unordered_access_view *view;
};
struct wined3d_cs_copy_sub_resource
struct wined3d_cs_generate_mipmaps
{
enum wined3d_cs_op opcode;
struct wined3d_resource *dst_resource;
unsigned int dst_sub_resource_idx;
struct wined3d_box dst_box;
struct wined3d_resource *src_resource;
unsigned int src_sub_resource_idx;
struct wined3d_box src_box;
struct wined3d_shader_resource_view *view;
};
struct wined3d_cs_stop
@ -766,10 +758,24 @@ void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs,
static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_gl_info *gl_info = &cs->device->adapter->gl_info;
struct wined3d_state *state = &cs->state;
const struct wined3d_cs_draw *op = data;
int load_base_vertex_idx;
unsigned int i;
/* ARB_draw_indirect always supports a base vertex offset. */
if (!op->parameters.indirect && !gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX])
load_base_vertex_idx = op->parameters.u.direct.base_vertex_idx;
else
load_base_vertex_idx = 0;
if (state->load_base_vertex_index != load_base_vertex_idx)
{
state->load_base_vertex_index = load_base_vertex_idx;
device_invalidate_state(cs->device, STATE_BASEVERTEXINDEX);
}
if (state->gl_primitive_type != op->primitive_type)
{
if (state->gl_primitive_type == GL_POINTS || op->primitive_type == GL_POINTS)
@ -778,26 +784,14 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
}
state->gl_patch_vertices = op->patch_vertex_count;
if (!op->parameters.indirect)
{
const struct wined3d_direct_draw_parameters *p = &op->parameters.u.direct;
if (!cs->device->adapter->gl_info.supported[ARB_DRAW_ELEMENTS_BASE_VERTEX]
&& state->load_base_vertex_index != p->base_vertex_idx)
{
state->load_base_vertex_index = p->base_vertex_idx;
device_invalidate_state(cs->device, STATE_BASEVERTEXINDEX);
}
}
draw_primitive(cs->device, state, &op->parameters);
if (op->parameters.indirect)
{
const struct wined3d_indirect_draw_parameters *p = &op->parameters.u.indirect;
wined3d_resource_release(&p->buffer->resource);
struct wined3d_buffer *buffer = op->parameters.u.indirect.buffer;
wined3d_resource_release(&buffer->resource);
}
if (op->parameters.indexed)
wined3d_resource_release(&state->index_buffer->resource);
for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
@ -815,7 +809,7 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
if (state->textures[i])
wined3d_resource_release(&state->textures[i]->resource);
}
for (i = 0; i < cs->device->adapter->gl_info.limits.buffers; ++i)
for (i = 0; i < gl_info->limits.buffers; ++i)
{
if (state->fb->render_targets[i])
wined3d_resource_release(state->fb->render_targets[i]->resource);
@ -827,13 +821,47 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
}
static void acquire_graphics_pipeline_resources(const struct wined3d_state *state,
BOOL indexed, const struct wined3d_gl_info *gl_info)
{
unsigned int i;
if (indexed)
wined3d_resource_acquire(&state->index_buffer->resource);
for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
{
if (state->streams[i].buffer)
wined3d_resource_acquire(&state->streams[i].buffer->resource);
}
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
{
if (state->stream_output[i].buffer)
wined3d_resource_acquire(&state->stream_output[i].buffer->resource);
}
for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
{
if (state->textures[i])
wined3d_resource_acquire(&state->textures[i]->resource);
}
for (i = 0; i < gl_info->limits.buffers; ++i)
{
if (state->fb->render_targets[i])
wined3d_resource_acquire(state->fb->render_targets[i]->resource);
}
if (state->fb->depth_stencil)
wined3d_resource_acquire(state->fb->depth_stencil->resource);
acquire_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL],
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
}
void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
unsigned int start_instance, unsigned int instance_count, BOOL indexed)
{
const struct wined3d_gl_info *gl_info = &cs->device->adapter->gl_info;
const struct wined3d_state *state = &cs->device->state;
struct wined3d_cs_draw *op;
unsigned int i;
op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_DRAW;
@ -847,33 +875,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned
op->parameters.u.direct.instance_count = instance_count;
op->parameters.indexed = indexed;
if (indexed)
wined3d_resource_acquire(&state->index_buffer->resource);
for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
{
if (state->streams[i].buffer)
wined3d_resource_acquire(&state->streams[i].buffer->resource);
}
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
{
if (state->stream_output[i].buffer)
wined3d_resource_acquire(&state->stream_output[i].buffer->resource);
}
for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
{
if (state->textures[i])
wined3d_resource_acquire(&state->textures[i]->resource);
}
for (i = 0; i < cs->device->adapter->gl_info.limits.buffers; ++i)
{
if (state->fb->render_targets[i])
wined3d_resource_acquire(state->fb->render_targets[i]->resource);
}
if (state->fb->depth_stencil)
wined3d_resource_acquire(state->fb->depth_stencil->resource);
acquire_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL],
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
acquire_graphics_pipeline_resources(state, indexed, gl_info);
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
}
@ -881,9 +883,9 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned
void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
struct wined3d_buffer *buffer, unsigned int offset, BOOL indexed)
{
const struct wined3d_gl_info *gl_info = &cs->device->adapter->gl_info;
const struct wined3d_state *state = &cs->device->state;
struct wined3d_cs_draw *op;
unsigned int i;
op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_DRAW;
@ -894,36 +896,9 @@ void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type,
op->parameters.u.indirect.offset = offset;
op->parameters.indexed = indexed;
acquire_graphics_pipeline_resources(state, indexed, gl_info);
wined3d_resource_acquire(&buffer->resource);
if (indexed)
wined3d_resource_acquire(&state->index_buffer->resource);
for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
{
if (state->streams[i].buffer)
wined3d_resource_acquire(&state->streams[i].buffer->resource);
}
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
{
if (state->stream_output[i].buffer)
wined3d_resource_acquire(&state->stream_output[i].buffer->resource);
}
for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
{
if (state->textures[i])
wined3d_resource_acquire(&state->textures[i]->resource);
}
for (i = 0; i < cs->device->adapter->gl_info.limits.buffers; ++i)
{
if (state->fb->render_targets[i])
wined3d_resource_acquire(state->fb->render_targets[i]->resource);
}
if (state->fb->depth_stencil)
wined3d_resource_acquire(state->fb->depth_stencil->resource);
acquire_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL],
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
}
@ -945,6 +920,7 @@ void wined3d_cs_emit_flush(struct wined3d_cs *cs)
op->opcode = WINED3D_CS_OP_FLUSH;
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
cs->queries_flushed = TRUE;
}
static void wined3d_cs_exec_set_predication(struct wined3d_cs *cs, const void *data)
@ -1054,8 +1030,7 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK));
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
}
else if (prev && (prev->format_flags & WINED3DFMT_FLAG_FLOAT)
!= (op->view->format_flags & WINED3DFMT_FLAG_FLOAT))
else if (prev && prev->format->depth_bias_scale != op->view->format->depth_bias_scale)
{
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
}
@ -1931,6 +1906,7 @@ void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *qu
op->flags = flags;
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
cs->queries_flushed = FALSE;
}
static void wined3d_cs_exec_preload_resource(struct wined3d_cs *cs, const void *data)
@ -2073,14 +2049,14 @@ static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void *
struct wined3d_context *context;
struct wined3d_bo_address addr;
if (op->flags)
if (op->flags & ~WINED3D_BLT_RAW)
{
FIXME("Flags %#x not implemented for %s resources.\n",
op->flags, debug_d3dresourcetype(op->dst_resource->type));
goto error;
}
if (op->src_resource->format != op->dst_resource->format)
if (!(op->flags & WINED3D_BLT_RAW) && op->src_resource->format != op->dst_resource->format)
{
FIXME("Format conversion not implemented for %s resources.\n",
debug_d3dresourcetype(op->dst_resource->type));
@ -2176,6 +2152,8 @@ void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_reso
op->flags = flags;
if (fx)
op->fx = *fx;
else
memset(&op->fx, 0, sizeof(op->fx));
op->filter = filter;
wined3d_resource_acquire(dst_resource);
@ -2199,11 +2177,18 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi
if (op->resource->type == WINED3D_RTYPE_BUFFER)
{
struct wined3d_buffer *buffer = buffer_from_resource(op->resource);
HRESULT hr;
if (FAILED(hr = wined3d_buffer_upload_data(buffer, box, op->data.data)))
WARN("Failed to update buffer data, hr %#x.\n", hr);
context = context_acquire(op->resource->device, NULL, 0);
if (!wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER))
{
ERR("Failed to load buffer location.\n");
context_release(context);
goto done;
}
wined3d_buffer_upload_data(buffer, context, box, op->data.data);
wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_BUFFER);
context_release(context);
goto done;
}
@ -2244,53 +2229,6 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r
unsigned int slice_pitch)
{
struct wined3d_cs_update_sub_resource *op;
#if defined(STAGING_CSMT)
size_t data_size, size;
if (resource->type != WINED3D_RTYPE_BUFFER && resource->format_flags & WINED3DFMT_FLAG_BLOCKS)
goto no_async;
data_size = 0;
switch (resource->type)
{
case WINED3D_RTYPE_TEXTURE_3D:
data_size += (box->back - box->front - 1) * slice_pitch;
/* fall-through */
case WINED3D_RTYPE_TEXTURE_2D:
data_size += (box->bottom - box->top - 1) * row_pitch;
/* fall-through */
case WINED3D_RTYPE_TEXTURE_1D:
data_size += (box->right - box->left) * resource->format->byte_count;
break;
case WINED3D_RTYPE_BUFFER:
data_size = box->right - box->left;
break;
case WINED3D_RTYPE_NONE:
return;
}
size = FIELD_OFFSET(struct wined3d_cs_update_sub_resource, copy_data[data_size]);
if (!cs->ops->check_space(cs, size, WINED3D_CS_QUEUE_DEFAULT))
goto no_async;
op = cs->ops->require_space(cs, size, WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
op->resource = resource;
op->sub_resource_idx = sub_resource_idx;
op->box = *box;
op->data.row_pitch = row_pitch;
op->data.slice_pitch = slice_pitch;
op->data.data = op->copy_data;
memcpy(op->copy_data, data, data_size);
wined3d_resource_acquire(resource);
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
return;
no_async:
wined3d_resource_wait_idle(resource);
#endif /* STAGING_CSMT */
op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_MAP);
op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
@ -2304,10 +2242,8 @@ no_async:
wined3d_resource_acquire(resource);
cs->ops->submit(cs, WINED3D_CS_QUEUE_MAP);
#if !defined(STAGING_CSMT)
/* The data pointer may go away, so we need to wait until it is read.
* Copying the data may be faster if it's small. */
#endif /* STAGING_CSMT */
cs->ops->finish(cs, WINED3D_CS_QUEUE_MAP);
}
@ -2386,7 +2322,6 @@ static void wined3d_cs_exec_copy_uav_counter(struct wined3d_cs *cs, const void *
context_release(context);
wined3d_resource_release(&op->buffer->resource);
wined3d_resource_release(view->resource);
}
void wined3d_cs_emit_copy_uav_counter(struct wined3d_cs *cs, struct wined3d_buffer *dst_buffer,
@ -2401,149 +2336,28 @@ void wined3d_cs_emit_copy_uav_counter(struct wined3d_cs *cs, struct wined3d_buff
op->view = uav;
wined3d_resource_acquire(&dst_buffer->resource);
wined3d_resource_acquire(uav->resource);
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
}
static void wined3d_cs_exec_copy_sub_resource(struct wined3d_cs *cs, const void *data)
static void wined3d_cs_exec_generate_mipmaps(struct wined3d_cs *cs, const void *data)
{
struct wined3d_cs_copy_sub_resource *op = (void*)data;
const struct wined3d_cs_generate_mipmaps *op = data;
struct wined3d_shader_resource_view *view = op->view;
if (op->dst_resource->type == WINED3D_RTYPE_BUFFER)
{
wined3d_buffer_copy(buffer_from_resource(op->dst_resource), op->dst_box.left,
buffer_from_resource(op->src_resource), op->src_box.left,
op->src_box.right - op->src_box.left);
}
else if (op->dst_resource->type == WINED3D_RTYPE_TEXTURE_1D ||
op->dst_resource->type == WINED3D_RTYPE_TEXTURE_2D ||
op->dst_resource->type == WINED3D_RTYPE_TEXTURE_3D)
{
struct wined3d_texture *dst_texture, *src_texture;
struct gl_texture *gl_tex_src, *gl_tex_dst;
unsigned int update_w, update_h, update_d;
const struct wined3d_gl_info *gl_info;
unsigned int src_level, src_layer;
unsigned int dst_level, dst_layer;
struct wined3d_context *context;
BOOL partial_update = FALSE;
update_w = op->dst_box.right - op->dst_box.left;
update_h = op->dst_box.bottom - op->dst_box.top;
update_d = op->dst_box.back - op->dst_box.front;
dst_texture = texture_from_resource(op->dst_resource);
src_texture = texture_from_resource(op->src_resource);
context = context_acquire(cs->device, NULL, 0);
gl_info = context->gl_info;
if (!wined3d_texture_load_location(src_texture, op->src_sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB))
{
FIXME("Failed to load source sub-resource into WINED3D_LOCATION_TEXTURE_RGB.\n");
context_release(context);
goto error;
}
src_level = op->src_sub_resource_idx % src_texture->level_count;
src_layer = op->src_sub_resource_idx / src_texture->level_count;
dst_level = op->dst_sub_resource_idx % dst_texture->level_count;
dst_layer = op->dst_sub_resource_idx / dst_texture->level_count;
switch (op->dst_resource->type)
{
case WINED3D_RTYPE_TEXTURE_3D:
partial_update |= (update_d != wined3d_texture_get_level_depth(dst_texture, dst_level));
case WINED3D_RTYPE_TEXTURE_2D:
partial_update |= (update_h != wined3d_texture_get_level_height(dst_texture, dst_level));
case WINED3D_RTYPE_TEXTURE_1D:
partial_update |= (update_w != wined3d_texture_get_level_width(dst_texture, dst_level));
default:
break;
}
if (!partial_update)
{
wined3d_texture_prepare_texture(dst_texture, context, FALSE);
}
else if (!wined3d_texture_load_location(dst_texture, op->dst_sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB))
{
FIXME("Failed to load destination sub-resource.\n");
context_release(context);
goto error;
}
switch (op->dst_resource->type)
{
case WINED3D_RTYPE_TEXTURE_1D:
op->src_box.top = src_layer;
op->dst_box.top = dst_layer;
break;
case WINED3D_RTYPE_TEXTURE_2D:
op->src_box.front = src_layer;
op->dst_box.front = dst_layer;
break;
default:
break;
}
gl_tex_src = wined3d_texture_get_gl_texture(src_texture, FALSE);
gl_tex_dst = wined3d_texture_get_gl_texture(dst_texture, FALSE);
GL_EXTCALL(glCopyImageSubData(gl_tex_src->name, src_texture->target, src_level,
op->src_box.left, op->src_box.top, op->src_box.front,
gl_tex_dst->name, dst_texture->target, dst_level,
op->dst_box.left, op->dst_box.top, op->dst_box.front,
update_w, update_h, update_d));
checkGLcall("Copy texture content");
wined3d_texture_validate_location(dst_texture, op->dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_invalidate_location(dst_texture, op->dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
context_release(context);
}
else
{
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(op->dst_resource->type));
}
error:
wined3d_resource_release(op->src_resource);
wined3d_resource_release(op->dst_resource);
shader_resource_view_generate_mipmaps(view);
wined3d_resource_release(view->resource);
}
void wined3d_cs_emit_copy_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource,
unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource,
unsigned int src_sub_resource_idx, const struct wined3d_box *src_box)
void wined3d_cs_emit_generate_mipmaps(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view)
{
const struct wined3d_gl_info *gl_info = &cs->device->adapter->gl_info;
struct wined3d_cs_blt_sub_resource *op;
if (!gl_info->supported[ARB_TEXTURE_VIEW] && src_resource->format->id != dst_resource->format->id)
{
FIXME("ARB_TEXTURE_VIEW not supported, cannot copy sub-resource.\n");
return;
}
if (!gl_info->supported[ARB_COPY_IMAGE])
{
wined3d_cs_emit_blt_sub_resource(cs, dst_resource, dst_sub_resource_idx, dst_box,
src_resource, src_sub_resource_idx, src_box, 0, NULL, WINED3D_TEXF_POINT);
return;
}
struct wined3d_cs_generate_mipmaps *op;
op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_COPY_SUB_RESOURCE;
op->dst_resource = dst_resource;
op->dst_sub_resource_idx = dst_sub_resource_idx;
op->dst_box = *dst_box;
op->src_resource = src_resource;
op->src_sub_resource_idx = src_sub_resource_idx;
op->src_box = *src_box;
op->opcode = WINED3D_CS_OP_GENERATE_MIPMAPS;
op->view = view;
wined3d_resource_acquire(dst_resource);
wined3d_resource_acquire(src_resource);
wined3d_resource_acquire(view->resource);
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
}
@ -2606,16 +2420,9 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION */ wined3d_cs_exec_add_dirty_texture_region,
/* WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_clear_unordered_access_view,
/* WINED3D_CS_OP_COPY_UAV_COUNTER */ wined3d_cs_exec_copy_uav_counter,
/* WINED3D_CS_OP_COPY_SUB_RESOURCE */ wined3d_cs_exec_copy_sub_resource,
/* WINED3D_CS_OP_GENERATE_MIPMAPS */ wined3d_cs_exec_generate_mipmaps,
};
#if defined(STAGING_CSMT)
static BOOL wined3d_cs_st_check_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
{
return TRUE;
}
#endif /* STAGING_CSMT */
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
{
if (size > (cs->data_size - cs->end))
@ -2669,9 +2476,6 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id
static const struct wined3d_cs_ops wined3d_cs_st_ops =
{
#if defined(STAGING_CSMT)
wined3d_cs_st_check_space,
#endif /* STAGING_CSMT */
wined3d_cs_st_require_space,
wined3d_cs_st_submit,
wined3d_cs_st_finish,
@ -2708,21 +2512,6 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id
wined3d_cs_queue_submit(&cs->queue[queue_id], cs);
}
#if defined(STAGING_CSMT)
static BOOL wined3d_cs_queue_check_space(struct wined3d_cs_queue *queue, size_t size)
{
size_t queue_size = ARRAY_SIZE(queue->data);
size_t header_size, packet_size, remaining;
header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]);
size = (size + header_size - 1) & ~(header_size - 1);
packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[size]);
remaining = queue_size - queue->head;
return (remaining >= packet_size);
}
#endif /* STAGING_CSMT */
static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size_t size, struct wined3d_cs *cs)
{
size_t queue_size = ARRAY_SIZE(queue->data);
@ -2784,16 +2573,6 @@ static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size
return packet->data;
}
#if defined(STAGING_CSMT)
static BOOL wined3d_cs_mt_check_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
{
if (cs->thread_id == GetCurrentThreadId())
return wined3d_cs_st_check_space(cs, size, queue_id);
return wined3d_cs_queue_check_space(&cs->queue[queue_id], size);
}
#endif /* STAGING_CSMT */
static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
{
if (cs->thread_id == GetCurrentThreadId())
@ -2816,9 +2595,6 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id
static const struct wined3d_cs_ops wined3d_cs_mt_ops =
{
#if defined(STAGING_CSMT)
wined3d_cs_mt_check_space,
#endif /* STAGING_CSMT */
wined3d_cs_mt_require_space,
wined3d_cs_mt_submit,
wined3d_cs_mt_finish,
@ -2866,11 +2642,16 @@ static DWORD WINAPI wined3d_cs_run(void *ctx)
unsigned int spin_count = 0;
struct wined3d_cs *cs = ctx;
enum wined3d_cs_op opcode;
HMODULE wined3d_module;
unsigned int poll = 0;
LONG tail;
TRACE("Started.\n");
/* Copy the module handle to a local variable to avoid racing with the
* thread freeing "cs" before the FreeLibraryAndExitThread() call. */
wined3d_module = cs->wined3d_module;
list_init(&cs->query_poll_list);
cs->thread_id = GetCurrentThreadId();
for (;;)
@ -2918,7 +2699,7 @@ static DWORD WINAPI wined3d_cs_run(void *ctx)
cs->queue[WINED3D_CS_QUEUE_MAP].tail = cs->queue[WINED3D_CS_QUEUE_MAP].head;
cs->queue[WINED3D_CS_QUEUE_DEFAULT].tail = cs->queue[WINED3D_CS_QUEUE_DEFAULT].head;
TRACE("Stopped.\n");
FreeLibraryAndExitThread(cs->wined3d_module, 0);
FreeLibraryAndExitThread(wined3d_module, 0);
}
struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)

View file

@ -374,8 +374,10 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
}
gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
for (i = 0; i < MAX_RENDER_TARGETS; ++i)
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITE(i)));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3));
gl_info->gl_ops.gl.p_glClearColor(color->r, color->g, color->b, color->a);
checkGLcall("glClearColor");
clear_mask = clear_mask | GL_COLOR_BUFFER_BIT;
@ -478,7 +480,7 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
state_cleanup(&device->state);
for (i = 0; i < sizeof(device->multistate_funcs) / sizeof(device->multistate_funcs[0]); ++i)
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
{
HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]);
device->multistate_funcs[i] = NULL;
@ -610,17 +612,6 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
* to each texture stage when the currently set D3D texture is NULL. */
context_active_texture(context, gl_info, 0);
gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_1d);
checkGLcall("glGenTextures");
TRACE("Dummy 1D texture given name %u.\n", device->dummy_textures.tex_1d);
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d);
checkGLcall("glBindTexture");
gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA8, 1, 0,
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color);
checkGLcall("glTexImage1D");
gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_2d);
checkGLcall("glGenTextures");
TRACE("Dummy 2D texture given name %u.\n", device->dummy_textures.tex_2d);
@ -697,17 +688,6 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
if (gl_info->supported[EXT_TEXTURE_ARRAY])
{
gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_1d_array);
checkGLcall("glGenTextures");
TRACE("Dummy 1D array texture given name %u.\n", device->dummy_textures.tex_1d_array);
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array);
checkGLcall("glBindTexture");
gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_1D_ARRAY, 0, GL_RGBA8, 1, 1, 0,
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color);
checkGLcall("glTexImage2D");
gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_2d_array);
checkGLcall("glGenTextures");
TRACE("Dummy 2D array texture given name %u.\n", device->dummy_textures.tex_2d_array);
@ -755,10 +735,7 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_buffer);
if (gl_info->supported[EXT_TEXTURE_ARRAY])
{
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_2d_array);
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_1d_array);
}
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP_ARRAY])
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_cube_array);
@ -773,7 +750,6 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_rect);
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_2d);
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_1d);
checkGLcall("Delete dummy textures");
@ -965,7 +941,7 @@ void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
static void device_init_swapchain_state(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
{
BOOL ds_enable = !!swapchain->desc.enable_auto_depth_stencil;
BOOL ds_enable = swapchain->desc.enable_auto_depth_stencil;
unsigned int i;
if (device->fb.render_targets)
@ -979,7 +955,6 @@ static void device_init_swapchain_state(struct wined3d_device *device, struct wi
}
wined3d_device_set_depth_stencil_view(device, ds_enable ? device->auto_depth_stencil_view : NULL);
wined3d_device_set_render_state(device, WINED3D_RS_ZENABLE, ds_enable);
}
static void wined3d_device_delete_opengl_contexts_cs(void *object)
@ -1046,6 +1021,7 @@ static void wined3d_device_create_primary_opengl_context_cs(void *object)
wined3d_ffp_blitter_create(&device->blitter, &device->adapter->gl_info);
wined3d_arbfp_blitter_create(&device->blitter, device);
wined3d_fbo_blitter_create(&device->blitter, &device->adapter->gl_info);
wined3d_raw_blitter_create(&device->blitter, &device->adapter->gl_info);
swapchain = device->swapchains[0];
target = swapchain->back_buffers ? swapchain->back_buffers[0] : swapchain->front_buffer;
@ -1223,9 +1199,6 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
wine_rb_clear(&device->samplers, device_free_sampler, NULL);
#if defined(STAGING_CSMT)
context_set_current(NULL);
#endif /* STAGING_CSMT */
wined3d_device_delete_opengl_contexts(device);
if (device->fb.depth_stencil)
@ -1311,33 +1284,8 @@ void CDECL wined3d_device_set_multithreaded(struct wined3d_device *device)
UINT CDECL wined3d_device_get_available_texture_mem(const struct wined3d_device *device)
{
/* const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; */
TRACE("device %p.\n", device);
/* We can not acquire the context unless there is a swapchain. */
/*
if (device->swapchains && gl_info->supported[NVX_GPU_MEMORY_INFO] &&
!wined3d_settings.emulated_textureram)
{
GLint vram_free_kb;
UINT64 vram_free;
struct wined3d_context *context = context_acquire(device, NULL, 0);
gl_info->gl_ops.gl.p_glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &vram_free_kb);
vram_free = (UINT64)vram_free_kb * 1024;
context_release(context);
TRACE("Total 0x%s bytes. emulation 0x%s left, driver 0x%s left.\n",
wine_dbgstr_longlong(device->adapter->vram_bytes),
wine_dbgstr_longlong(device->adapter->vram_bytes - device->adapter->vram_bytes_used),
wine_dbgstr_longlong(vram_free));
vram_free = min(vram_free, device->adapter->vram_bytes - device->adapter->vram_bytes_used);
return min(UINT_MAX, vram_free);
}
*/
TRACE("Emulating 0x%s bytes. 0x%s used, returning 0x%s left.\n",
wine_dbgstr_longlong(device->adapter->vram_bytes),
wine_dbgstr_longlong(device->adapter->vram_bytes_used),
@ -1800,7 +1748,6 @@ HRESULT CDECL wined3d_device_set_clip_plane(struct wined3d_device *device,
{
TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
/* Validate plane_idx. */
if (plane_idx >= device->adapter->gl_info.limits.user_clip_distances)
{
TRACE("Application has requested clipplane this device doesn't support.\n");
@ -1829,7 +1776,6 @@ HRESULT CDECL wined3d_device_get_clip_plane(const struct wined3d_device *device,
{
TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
/* Validate plane_idx. */
if (plane_idx >= device->adapter->gl_info.limits.user_clip_distances)
{
TRACE("Application has requested clipplane this device doesn't support.\n");
@ -2076,7 +2022,7 @@ void CDECL wined3d_device_set_sampler_state(struct wined3d_device *device,
if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3)
sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
if (sampler_idx >= sizeof(device->state.sampler_states) / sizeof(*device->state.sampler_states))
if (sampler_idx >= ARRAY_SIZE(device->state.sampler_states))
{
WARN("Invalid sampler %u.\n", sampler_idx);
return; /* Windows accepts overflowing this array ... we do not. */
@ -2111,7 +2057,7 @@ DWORD CDECL wined3d_device_get_sampler_state(const struct wined3d_device *device
if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3)
sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
if (sampler_idx >= sizeof(device->state.sampler_states) / sizeof(*device->state.sampler_states))
if (sampler_idx >= ARRAY_SIZE(device->state.sampler_states))
{
WARN("Invalid sampler %u.\n", sampler_idx);
return 0; /* Windows accepts overflowing this array ... we do not. */
@ -3467,7 +3413,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
/* Windows accepts overflowing this array... we do not. */
if (stage >= sizeof(device->state.textures) / sizeof(*device->state.textures))
if (stage >= ARRAY_SIZE(device->state.textures))
{
WARN("Ignoring invalid stage %u.\n", stage);
return WINED3D_OK;
@ -3511,7 +3457,7 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d
if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
if (stage >= sizeof(device->state.textures) / sizeof(*device->state.textures))
if (stage >= ARRAY_SIZE(device->state.textures))
{
WARN("Ignoring invalid stage %u.\n", stage);
return NULL; /* Windows accepts overflowing this array ... we do not. */
@ -3522,17 +3468,10 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d
HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, WINED3DCAPS *caps)
{
HRESULT hr;
TRACE("device %p, caps %p.\n", device, caps);
hr = wined3d_get_device_caps(device->wined3d, device->adapter->ordinal,
return wined3d_get_device_caps(device->wined3d, device->adapter->ordinal,
device->create_parms.device_type, caps);
if (SUCCEEDED(hr) && use_software_vertex_processing(device))
caps->MaxVertexBlendMatrixIndex = 255;
return hr;
}
HRESULT CDECL wined3d_device_get_display_mode(const struct wined3d_device *device, UINT swapchain_idx,
@ -3962,15 +3901,31 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device
void CDECL wined3d_device_set_software_vertex_processing(struct wined3d_device *device, BOOL software)
{
static BOOL warned;
TRACE("device %p, software %#x.\n", device, software);
if (!warned)
{
FIXME("device %p, software %#x stub!\n", device, software);
warned = TRUE;
}
device->softwareVertexProcessing = software;
}
BOOL CDECL wined3d_device_get_software_vertex_processing(const struct wined3d_device *device)
{
static BOOL warned;
TRACE("device %p.\n", device);
if (!warned)
{
TRACE("device %p stub!\n", device);
warned = TRUE;
}
return device->softwareVertexProcessing;
}
@ -4027,12 +3982,6 @@ void CDECL wined3d_device_copy_uav_counter(struct wined3d_device *device,
TRACE("device %p, dst_buffer %p, offset %u, uav %p.\n",
device, dst_buffer, offset, uav);
if (offset + sizeof(GLuint) > dst_buffer->resource.size)
{
WARN("Offset %u too large.\n", offset);
return;
}
wined3d_cs_emit_copy_uav_counter(device->cs, dst_buffer, offset, uav);
}
@ -4069,12 +4018,10 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
return;
}
if (src_resource->format->id != dst_resource->format->id &&
(src_resource->format->typeless_id != dst_resource->format->typeless_id ||
src_resource->format->gl_view_class != dst_resource->format->gl_view_class ||
!src_resource->format->typeless_id))
if (src_resource->format->typeless_id != dst_resource->format->typeless_id
|| (!src_resource->format->typeless_id && src_resource->format->id != dst_resource->format->id))
{
WARN("Resource formats (%s / %s) don't match.\n",
WARN("Resource formats %s and %s are incompatible.\n",
debug_d3dformat(dst_resource->format->id),
debug_d3dformat(src_resource->format->id));
return;
@ -4083,7 +4030,8 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
if (dst_resource->type == WINED3D_RTYPE_BUFFER)
{
wined3d_box_set(&box, 0, 0, src_resource->size, 1, 0, 1);
wined3d_cs_emit_copy_sub_resource(device->cs, dst_resource, 0, &box, src_resource, 0, &box);
wined3d_cs_emit_blt_sub_resource(device->cs, dst_resource, 0, &box,
src_resource, 0, &box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT);
return;
}
@ -4109,7 +4057,8 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
{
unsigned int idx = j * dst_texture->level_count + i;
wined3d_cs_emit_copy_sub_resource(device->cs, dst_resource, idx, &box, src_resource, idx, &box);
wined3d_cs_emit_blt_sub_resource(device->cs, dst_resource, idx, &box,
src_resource, idx, &box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT);
}
}
}
@ -4140,12 +4089,10 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
return WINED3DERR_INVALIDCALL;
}
if (src_resource->format->id != dst_resource->format->id &&
(src_resource->format->typeless_id != dst_resource->format->typeless_id ||
src_resource->format->gl_view_class != dst_resource->format->gl_view_class ||
!src_resource->format->typeless_id))
if (src_resource->format->typeless_id != dst_resource->format->typeless_id
|| (!src_resource->format->typeless_id && src_resource->format->id != dst_resource->format->id))
{
WARN("Resource formats (%s / %s) don't match.\n",
WARN("Resource formats %s and %s are incompatible.\n",
debug_d3dformat(dst_resource->format->id),
debug_d3dformat(src_resource->format->id));
return WINED3DERR_INVALIDCALL;
@ -4167,7 +4114,10 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
if (!src_box)
{
wined3d_box_set(&b, 0, 0, src_resource->size, 1, 0, 1);
unsigned int dst_w;
dst_w = dst_resource->size - dst_x;
wined3d_box_set(&b, 0, 0, min(src_resource->size, dst_w), 1, 0, 1);
src_box = &b;
}
else if ((src_box->left >= src_box->right
@ -4206,7 +4156,6 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
return WINED3DERR_INVALIDCALL;
}
#if !defined(STAGING_CSMT)
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count)
{
WARN("Destination sub-resource %u is mapped.\n", dst_sub_resource_idx);
@ -4217,25 +4166,20 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
{
WARN("Source sub-resource %u is mapped.\n", src_sub_resource_idx);
return WINED3DERR_INVALIDCALL;
#else /* STAGING_CSMT */
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count ||
src_texture->sub_resources[src_sub_resource_idx].map_count)
{
struct wined3d_device *device = dst_texture->resource.device;
device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count ||
src_texture->sub_resources[src_sub_resource_idx].map_count)
{
WARN("Destination or source sub-resource is mapped.\n");
return WINEDDERR_SURFACEBUSY;
}
#endif /* STAGING_CSMT */
}
if (!src_box)
{
wined3d_box_set(&b, 0, 0, wined3d_texture_get_level_width(src_texture, src_level),
wined3d_texture_get_level_height(src_texture, src_level), 0, 1);
unsigned int src_w, src_h, dst_w, dst_h, dst_level;
src_w = wined3d_texture_get_level_width(src_texture, src_level);
src_h = wined3d_texture_get_level_height(src_texture, src_level);
dst_level = dst_sub_resource_idx % dst_texture->level_count;
dst_w = wined3d_texture_get_level_width(dst_texture, dst_level) - dst_x;
dst_h = wined3d_texture_get_level_height(dst_texture, dst_level) - dst_y;
wined3d_box_set(&b, 0, 0, min(src_w, dst_w), min(src_h, dst_h), 0, 1);
src_box = &b;
}
else if (FAILED(wined3d_texture_check_box_dimensions(src_texture, src_level, src_box)))
@ -4259,8 +4203,8 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
return WINED3DERR_INVALIDCALL;
}
wined3d_cs_emit_copy_sub_resource(device->cs, dst_resource, dst_sub_resource_idx, &dst_box,
src_resource, src_sub_resource_idx, src_box);
wined3d_cs_emit_blt_sub_resource(device->cs, dst_resource, dst_sub_resource_idx, &dst_box,
src_resource, src_sub_resource_idx, src_box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT);
return WINED3D_OK;
}
@ -4287,8 +4231,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
height = 1;
depth = 1;
}
else if (resource->type == WINED3D_RTYPE_TEXTURE_1D ||
resource->type == WINED3D_RTYPE_TEXTURE_2D || resource->type == WINED3D_RTYPE_TEXTURE_3D)
else if (resource->type == WINED3D_RTYPE_TEXTURE_2D || resource->type == WINED3D_RTYPE_TEXTURE_3D)
{
struct wined3d_texture *texture = texture_from_resource(resource);
unsigned int level;
@ -4323,10 +4266,8 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
return;
}
#if !defined(STAGING_CSMT)
wined3d_resource_wait_idle(resource);
#endif /* STAGING_CSMT */
wined3d_cs_emit_update_sub_resource(device->cs, resource, sub_resource_idx, box, data, row_pitch, depth_pitch);
}
@ -5054,7 +4995,6 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
switch (type)
{
case WINED3D_RTYPE_TEXTURE_1D:
case WINED3D_RTYPE_TEXTURE_2D:
case WINED3D_RTYPE_TEXTURE_3D:
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
@ -5187,7 +5127,7 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
return WINED3D_OK;
err:
for (i = 0; i < sizeof(device->multistate_funcs) / sizeof(device->multistate_funcs[0]); ++i)
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
{
HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]);
}
@ -5275,58 +5215,3 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
else
return CallWindowProcA(proc, window, message, wparam, lparam);
}
#if defined(STAGING_CSMT)
/* Context activation is done by the caller */
struct wined3d_gl_bo *wined3d_device_get_bo(struct wined3d_device *device, UINT size, GLenum gl_usage,
GLenum type_hint, struct wined3d_context *context)
{
struct wined3d_gl_bo *ret;
const struct wined3d_gl_info *gl_info;
TRACE("device %p, size %u, gl_usage %u, type_hint %u\n", device, size, gl_usage,
type_hint);
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
if(!ret)
return NULL;
ret->type_hint = type_hint;
ret->size = size;
ret->usage = gl_usage;
gl_info = context->gl_info;
GL_EXTCALL(glGenBuffers(1, &ret->name));
if (type_hint == GL_ELEMENT_ARRAY_BUFFER)
context_invalidate_state(context, STATE_INDEXBUFFER);
GL_EXTCALL(glBindBuffer(type_hint, ret->name));
GL_EXTCALL(glBufferData(type_hint, size, NULL, gl_usage));
GL_EXTCALL(glBindBuffer(type_hint, 0));
checkGLcall("Create buffer object");
TRACE("Successfully created and set up buffer %u\n", ret->name);
return ret;
}
/* Context activation is done by the caller */
static void wined3d_device_destroy_bo(struct wined3d_device *device, const struct wined3d_context *context,
struct wined3d_gl_bo *bo)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
TRACE("device %p, bo %p, GL bo %u\n", device, bo, bo->name);
GL_EXTCALL(glDeleteBuffers(1, &bo->name));
checkGLcall("glDeleteBuffers");
HeapFree(GetProcessHeap(), 0, bo);
}
/* Context activation is done by the caller */
void wined3d_device_release_bo(struct wined3d_device *device, struct wined3d_gl_bo *bo,
const struct wined3d_context *context)
{
TRACE("device %p, bo %p, GL bo %u\n", device, bo, bo->name);
wined3d_device_destroy_bo(device, context, bo);
}
#endif /* STAGING_CSMT */

View file

@ -116,9 +116,9 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH },
{"GL_ARB_copy_buffer", ARB_COPY_BUFFER },
{"GL_ARB_copy_image", ARB_COPY_IMAGE },
{"GL_ARB_cull_distance", ARB_CULL_DISTANCE },
{"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
{"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
{"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP },
{"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
{"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL },
{"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
@ -176,6 +176,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_ARB_texture_cube_map_array", ARB_TEXTURE_CUBE_MAP_ARRAY },
{"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE },
{"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 },
{"GL_ARB_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC},
{"GL_ARB_texture_float", ARB_TEXTURE_FLOAT },
{"GL_ARB_texture_gather", ARB_TEXTURE_GATHER },
{"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT },
@ -234,7 +235,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC },
{"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE },
{"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 },
{"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC},
{"GL_EXT_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC},
{"GL_EXT_texture_integer", EXT_TEXTURE_INTEGER },
{"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS },
{"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP },
@ -264,7 +265,6 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 },
{"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION },
{"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 },
{"GL_NVX_gpu_memory_info", NVX_GPU_MEMORY_INFO },
/* SGI */
{"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP },
@ -581,7 +581,7 @@ static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
};
unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
unsigned int check[ARRAY_SIZE(pattern)];
/* No PBO -> No point in testing them. */
if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
@ -1338,7 +1338,6 @@ static const struct gpu_description gpu_description_table[] =
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE8, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE8, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560M, "NVIDIA GeForce GTX 560M", DRIVER_NVIDIA_GEFORCE8, 3072},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE8, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE8, 1280},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE8, 1536},
@ -1486,6 +1485,7 @@ static const struct gpu_description gpu_description_table[] =
{HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_HD4000, 1536},
{HW_VENDOR_INTEL, CARD_INTEL_HWD, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
{HW_VENDOR_INTEL, CARD_INTEL_HWM, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536},
{HW_VENDOR_INTEL, CARD_INTEL_HD5000, "Intel(R) HD Graphics 5000", DRIVER_INTEL_HD4000, 1536},
{HW_VENDOR_INTEL, CARD_INTEL_I5100_1, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
{HW_VENDOR_INTEL, CARD_INTEL_I5100_2, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
{HW_VENDOR_INTEL, CARD_INTEL_I5100_3, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536},
@ -1527,7 +1527,7 @@ static const struct driver_version_information *get_driver_version_info(enum win
unsigned int i;
TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model);
for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++)
for (i = 0; i < ARRAY_SIZE(driver_version_table); ++i)
{
const struct driver_version_information *entry = &driver_version_table[i];
@ -1547,7 +1547,7 @@ static const struct gpu_description *get_gpu_description(enum wined3d_pci_vendor
{
unsigned int i;
for (i = 0; i < (sizeof(gpu_description_table) / sizeof(*gpu_description_table)); ++i)
for (i = 0; i < ARRAY_SIZE(gpu_description_table); ++i)
{
if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card)
return &gpu_description_table[i];
@ -1576,15 +1576,6 @@ static const struct gpu_description *query_gpu_description(const struct wined3d_
TRACE("Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n",
vendor, device, wine_dbgstr_longlong(*vram_bytes));
}
else if (gl_info->supported[NVX_GPU_MEMORY_INFO])
{
GLint vram_kb;
gl_info->gl_ops.gl.p_glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &vram_kb);
*vram_bytes = (UINT64)vram_kb * 1024;
TRACE("Got 0x%s as video memory from NVX_GPU_MEMORY_INFO extension.\n",
wine_dbgstr_longlong(*vram_bytes));
}
if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
{
@ -1696,13 +1687,11 @@ static void init_driver_info(struct wined3d_driver_info *driver_info,
* In order to avoid this application bug we limit the amount of video memory
* to LONG_MAX for older Windows versions.
*/
#ifdef __i386__
if (driver_model < DRIVER_MODEL_NT6X && driver_info->vram_bytes > LONG_MAX)
{
TRACE("Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n", LONG_MAX);
driver_info->vram_bytes = LONG_MAX;
}
#endif
/* Try to obtain driver version information for the current Windows version. This fails in
* some cases:
@ -1744,7 +1733,7 @@ static void fixup_extensions(struct wined3d_gl_info *gl_info, struct wined3d_cap
{
unsigned int i;
for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
for (i = 0; i < ARRAY_SIZE(quirk_table); ++i)
{
if (!quirk_table[i].match(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device)) continue;
TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description);
@ -1799,7 +1788,6 @@ static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_in
return GL_VENDOR_FGLRX;
if (strstr(gl_vendor_string, "Mesa")
|| strstr(gl_vendor_string, "Brian Paul")
|| strstr(gl_vendor_string, "X.Org")
|| strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
|| strstr(gl_vendor_string, "DRI R300 Project")
@ -1954,7 +1942,6 @@ cards_nvidia_binary[] =
{"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
{"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
{"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */
{"GTX 560M", CARD_NVIDIA_GEFORCE_GTX560M}, /* Geforce 500 - midend mobile */
{"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
{"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */
{"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */
@ -2167,6 +2154,7 @@ cards_intel[] =
/* Haswell */
{"Iris Pro 5200", CARD_INTEL_IP5200_1},
{"Iris 5100", CARD_INTEL_I5100_1},
{"HD Graphics 5000", CARD_INTEL_HD5000}, /* MacOS */
{"Haswell Mobile", CARD_INTEL_HWM},
{"Iris OpenGL Engine", CARD_INTEL_HWM}, /* MacOS */
/* Ivybridge */
@ -2494,16 +2482,16 @@ static const struct
card_vendor_table[] =
{
{HW_VENDOR_AMD, "AMD", amd_gl_vendor_table,
sizeof(amd_gl_vendor_table) / sizeof(*amd_gl_vendor_table),
ARRAY_SIZE(amd_gl_vendor_table),
card_fallback_amd},
{HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table,
sizeof(nvidia_gl_vendor_table) / sizeof(*nvidia_gl_vendor_table),
ARRAY_SIZE(nvidia_gl_vendor_table),
card_fallback_nvidia},
{HW_VENDOR_VMWARE, "VMware", vmware_gl_vendor_table,
sizeof(vmware_gl_vendor_table) / sizeof(*vmware_gl_vendor_table),
ARRAY_SIZE(vmware_gl_vendor_table),
card_fallback_amd},
{HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table,
sizeof(intel_gl_vendor_table) / sizeof(*intel_gl_vendor_table),
ARRAY_SIZE(intel_gl_vendor_table),
card_fallback_intel},
};
@ -2565,7 +2553,7 @@ static enum wined3d_pci_device wined3d_guess_card(const struct shader_caps *shad
enum wined3d_d3d_level d3d_level = d3d_level_from_caps(shader_caps, fragment_caps, glsl_version);
enum wined3d_pci_device device;
for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i)
for (i = 0; i < ARRAY_SIZE(card_vendor_table); ++i)
{
if (card_vendor_table[i].card_vendor != *card_vendor)
continue;
@ -3524,12 +3512,6 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
gl_info->limits.buffers = gl_max;
TRACE("Max draw buffers: %u.\n", gl_max);
}
if (gl_info->supported[ARB_BLEND_FUNC_EXTENDED])
{
gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &gl_max);
gl_info->limits.dual_buffers = gl_max;
TRACE("Max dual source draw buffers: %u.\n", gl_max);
}
if (gl_info->supported[ARB_MULTITEXTURE])
{
if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
@ -3625,9 +3607,9 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
gl_info->limits.texture3d_size = gl_max;
TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
}
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
{
gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &gl_max);
gl_info->limits.anisotropy = gl_max;
TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
}
@ -3906,6 +3888,8 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
{ARB_ES2_COMPATIBILITY, MAKEDWORD_VERSION(4, 1)},
{ARB_VIEWPORT_ARRAY, MAKEDWORD_VERSION(4, 1)},
{ARB_BASE_INSTANCE, MAKEDWORD_VERSION(4, 2)},
{ARB_CONSERVATIVE_DEPTH, MAKEDWORD_VERSION(4, 2)},
{ARB_INTERNALFORMAT_QUERY, MAKEDWORD_VERSION(4, 2)},
{ARB_MAP_BUFFER_ALIGNMENT, MAKEDWORD_VERSION(4, 2)},
{ARB_SHADER_ATOMIC_COUNTERS, MAKEDWORD_VERSION(4, 2)},
@ -3932,9 +3916,11 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
{ARB_CLEAR_TEXTURE, MAKEDWORD_VERSION(4, 4)},
{ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)},
{ARB_CULL_DISTANCE, MAKEDWORD_VERSION(4, 5)},
{ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)},
{ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)},
{ARB_TEXTURE_FILTER_ANISOTROPIC, MAKEDWORD_VERSION(4, 6)},
};
struct wined3d_driver_info *driver_info = &adapter->driver_info;
const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
@ -4004,13 +3990,11 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
ERR("Received a NULL GL_EXTENSIONS.\n");
return FALSE;
}
parse_extension_string(gl_info, gl_extensions, gl_extension_map,
sizeof(gl_extension_map) / sizeof(*gl_extension_map));
parse_extension_string(gl_info, gl_extensions, gl_extension_map, ARRAY_SIZE(gl_extension_map));
}
else
{
enumerate_gl_extensions(gl_info, gl_extension_map,
sizeof(gl_extension_map) / sizeof(*gl_extension_map));
enumerate_gl_extensions(gl_info, gl_extension_map, ARRAY_SIZE(gl_extension_map));
}
hdc = wglGetCurrentDC();
@ -4020,8 +4004,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
if (!WGL_Extensions)
WARN("WGL extensions not supported.\n");
else
parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map,
sizeof(wgl_extension_map) / sizeof(*wgl_extension_map));
parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map, ARRAY_SIZE(wgl_extension_map));
for (i = 0; i < ARRAY_SIZE(core_extensions); ++i)
{
@ -4233,9 +4216,17 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
if (gl_info->supported[ARB_TEXTURE_STORAGE] && gl_info->supported[APPLE_YCBCR_422])
{
/* AFAIK APPLE_ycbcr_422 is only available in legacy contexts so we shouldn't ever hit this. */
FIXME("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n");
ERR("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n");
gl_info->supported[APPLE_YCBCR_422] = FALSE;
}
if (gl_info->supported[ARB_DRAW_INDIRECT] && !gl_info->supported[ARB_BASE_INSTANCE])
{
/* If ARB_base_instance is not supported the baseInstance field
* in indirect draw parameters must be 0 or behavior is undefined.
*/
WARN("Disabling ARB_draw_indirect because ARB_base_instance is not supported.\n");
gl_info->supported[ARB_DRAW_INDIRECT] = FALSE;
}
wined3d_adapter_init_limits(gl_info);
@ -4293,10 +4284,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
for (i = 0; i < gl_info->limits.buffers; ++i)
adapter->d3d_info.valid_rt_mask |= (1u << i);
adapter->d3d_info.valid_dual_rt_mask = 0;
for (i = 0; i < gl_info->limits.dual_buffers; ++i)
adapter->d3d_info.valid_dual_rt_mask |= (1u << i);
if (!adapter->d3d_info.shader_color_key)
{
/* We do not want to deal with re-creating immutable texture storage for color keying emulation. */
@ -5257,6 +5244,13 @@ static BOOL wined3d_check_surface_capability(const struct wined3d_format *format
return TRUE;
}
if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE))
== (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE))
{
TRACE("[OK]\n");
return TRUE;
}
/* Reject other formats */
TRACE("[FAILED]\n");
return FALSE;
@ -5276,10 +5270,9 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
{
const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id,
WINED3DUSAGE_RENDERTARGET);
const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id, usage);
const struct wined3d_format *adapter_format, *format;
enum wined3d_gl_resource_type gl_type, gl_type_end;
BOOL mipmap_autogen_supported;
DWORD format_flags = 0;
DWORD allowed_usage;
@ -5292,28 +5285,18 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
adapter_format = wined3d_get_format(gl_info, adapter_format_id, WINED3DUSAGE_RENDERTARGET);
format = wined3d_get_format(gl_info, check_format_id, usage);
switch (resource_type)
{
case WINED3D_RTYPE_NONE:
allowed_usage = WINED3DUSAGE_DEPTHSTENCIL
| WINED3DUSAGE_RENDERTARGET;
gl_type = WINED3D_GL_RES_TYPE_TEX_1D;
gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
break;
case WINED3D_RTYPE_TEXTURE_1D:
allowed_usage = WINED3DUSAGE_DYNAMIC
| WINED3DUSAGE_SOFTWAREPROCESSING
| WINED3DUSAGE_TEXTURE
| WINED3DUSAGE_QUERY_FILTER
| WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
| WINED3DUSAGE_QUERY_SRGBREAD
| WINED3DUSAGE_QUERY_SRGBWRITE
| WINED3DUSAGE_QUERY_VERTEXTEXTURE
| WINED3DUSAGE_QUERY_WRAPANDMIP;
gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_1D;
break;
case WINED3D_RTYPE_TEXTURE_2D:
allowed_usage = WINED3DUSAGE_DEPTHSTENCIL
| WINED3DUSAGE_RENDERTARGET
@ -5370,12 +5353,6 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D;
break;
case WINED3D_RTYPE_BUFFER:
allowed_usage = WINED3DUSAGE_DYNAMIC
| WINED3DUSAGE_QUERY_VERTEXTEXTURE;
gl_type = gl_type_end = WINED3D_GL_RES_TYPE_BUFFER;
break;
default:
FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
return WINED3DERR_NOTAVAILABLE;
@ -5409,12 +5386,7 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
return WINED3DERR_NOTAVAILABLE;
}
if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !gl_info->supported[SGIS_GENERATE_MIPMAP])
{
TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
return WINED3DOK_NOAUTOGEN;
}
mipmap_autogen_supported = gl_info->supported[SGIS_GENERATE_MIPMAP];
for (; gl_type <= gl_type_end; ++gl_type)
{
if ((format->flags[gl_type] & format_flags) != format_flags)
@ -5443,6 +5415,18 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
debug_d3dformat(check_format_id));
return WINED3DERR_NOTAVAILABLE;
}
if ((format->flags[gl_type] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))
!= (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))
{
mipmap_autogen_supported = FALSE;
}
}
if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !mipmap_autogen_supported)
{
TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n");
return WINED3DOK_NOAUTOGEN;
}
return WINED3D_OK;
@ -5678,7 +5662,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
WINED3DPRASTERCAPS_DEPTHBIAS;
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
{
caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
WINED3DPRASTERCAPS_ZBIAS |
@ -5797,7 +5781,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
WINED3DPTFILTERCAPS_MIPNEAREST |
WINED3DPTFILTERCAPS_NEAREST;
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
{
caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
WINED3DPTFILTERCAPS_MINFANISOTROPIC;
@ -5818,7 +5802,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
WINED3DPTFILTERCAPS_MIPNEAREST |
WINED3DPTFILTERCAPS_NEAREST;
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
{
caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
WINED3DPTFILTERCAPS_MINFANISOTROPIC;
@ -5978,10 +5962,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
caps->MaxUserClipPlanes = vertex_caps.max_user_clip_planes;
caps->MaxActiveLights = vertex_caps.max_active_lights;
caps->MaxVertexBlendMatrices = vertex_caps.max_vertex_blend_matrices;
if (device_type == WINED3D_DEVICE_TYPE_HAL)
caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index;
else
caps->MaxVertexBlendMatrixIndex = 255;
caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index;
caps->VertexProcessingCaps = vertex_caps.vertex_processing_caps;
caps->FVFCaps = vertex_caps.fvf_caps;
caps->RasterCaps |= vertex_caps.raster_caps;
@ -6550,30 +6531,35 @@ static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc
}
}
static BOOL has_extension(const char *list, const char *ext)
static DWORD get_max_gl_version(const struct wined3d_gl_info *gl_info, DWORD flags)
{
size_t len = strlen(ext);
while (list)
{
while (*list == ' ') list++;
if (!strncmp(list, ext, len) && (!list[len] || list[len] == ' ')) return TRUE;
list = strchr(list, ' ');
}
return FALSE;
const char *gl_vendor, *gl_renderer;
if (wined3d_settings.explicit_gl_version || (flags & WINED3D_PIXEL_CENTER_INTEGER))
return wined3d_settings.max_gl_version;
gl_vendor = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR);
gl_renderer = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
if (!gl_vendor || !gl_renderer
|| wined3d_guess_card_vendor(gl_vendor, gl_renderer) == HW_VENDOR_NVIDIA)
return wined3d_settings.max_gl_version;
return MAKEDWORD_VERSION(4, 4);
}
static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, DWORD wined3d_creation_flags)
{
static const DWORD supported_gl_versions[] =
{
MAKEDWORD_VERSION(4, 4),
MAKEDWORD_VERSION(3, 2),
MAKEDWORD_VERSION(1, 0),
};
struct wined3d_gl_info *gl_info = &adapter->gl_info;
struct wined3d_caps_gl_ctx caps_gl_ctx = {0};
DWORD max_gl_version = wined3d_settings.max_gl_version;
DISPLAY_DEVICEW display_device;
unsigned int i;
DISPLAY_DEVICEW display_device;
DWORD max_gl_version;
TRACE("adapter %p, ordinal %u.\n", adapter, ordinal);
@ -6618,16 +6604,7 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal,
return FALSE;
}
if (wined3d_creation_flags & WINED3D_REQUEST_D3D10)
{
const char *gl_extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
if (!has_extension(gl_extensions, "GL_ARB_compatibility"))
{
ERR_(winediag)("GL_ARB_compatibility not supported, requesting context with GL version 3.2.\n");
max_gl_version = MAKEDWORD_VERSION(3, 2);
}
}
max_gl_version = get_max_gl_version(gl_info, wined3d_creation_flags);
for (i = 0; i < ARRAY_SIZE(supported_gl_versions); ++i)
{
if (supported_gl_versions[i] <= max_gl_version)
@ -6681,10 +6658,6 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal,
return FALSE;
}
gl_info->fixed_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH_COMPONENT);
if (gl_info->supported[ARB_DEPTH_BUFFER_FLOAT])
gl_info->float_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH32F_STENCIL8);
adapter->vram_bytes = adapter->driver_info.vram_bytes;
adapter->vram_bytes_used = 0;
TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));

View file

@ -162,133 +162,6 @@ static void draw_primitive_arrays(struct wined3d_context *context, const struct
}
}
/* Context activation is done by the caller. */
static void draw_primitive_arrays_indirect(struct wined3d_context *context, const struct wined3d_state *state,
const void *idx_data, unsigned int idx_size, struct wined3d_buffer *buffer, unsigned int offset)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
if (!gl_info->supported[ARB_DRAW_INDIRECT])
{
FIXME("Indirect draw not supported.\n");
return;
}
wined3d_buffer_load(buffer, context, state);
GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer->buffer_object));
if (idx_size)
{
GLenum idx_type = (idx_size == 2) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
GL_EXTCALL(glDrawElementsIndirect(state->gl_primitive_type, idx_type,
(const BYTE *)NULL + offset));
}
else
{
GL_EXTCALL(glDrawArraysIndirect(state->gl_primitive_type,
(const BYTE *)NULL + offset));
}
GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0));
checkGLcall("draw indirect");
}
static const BYTE *software_vertex_blending(struct wined3d_context *context,
const struct wined3d_state *state, const struct wined3d_stream_info *si,
unsigned int element_idx, unsigned int stride_idx, float *result)
{
#define SI_FORMAT(idx) (si->elements[(idx)].format->emit_idx)
#define SI_PTR(idx1, idx2) (si->elements[(idx1)].data.addr + si->elements[(idx1)].stride * (idx2))
const float *data = (const float *)SI_PTR(element_idx, stride_idx);
float vector[4] = {0.0f, 0.0f, 0.0f, 1.0f};
float cur_weight, weight_sum = 0.0f;
struct wined3d_matrix m;
const BYTE *blend_index;
const float *weights;
int i, num_weights;
if (element_idx != WINED3D_FFP_POSITION && element_idx != WINED3D_FFP_NORMAL)
return (BYTE *)data;
if (!use_indexed_vertex_blending(state, si) || !use_software_vertex_processing(context->device))
return (BYTE *)data;
if (!si->elements[WINED3D_FFP_BLENDINDICES].data.addr ||
!si->elements[WINED3D_FFP_BLENDWEIGHT].data.addr)
{
FIXME("no blend indices / weights set\n");
return (BYTE *)data;
}
if (SI_FORMAT(WINED3D_FFP_BLENDINDICES) != WINED3D_FFP_EMIT_UBYTE4)
{
FIXME("unsupported blend index format: %u\n", SI_FORMAT(WINED3D_FFP_BLENDINDICES));
return (BYTE *)data;
}
/* FIXME: validate weight format */
switch (state->render_states[WINED3D_RS_VERTEXBLEND])
{
case WINED3D_VBF_0WEIGHTS: num_weights = 0; break;
case WINED3D_VBF_1WEIGHTS: num_weights = 1; break;
case WINED3D_VBF_2WEIGHTS: num_weights = 2; break;
case WINED3D_VBF_3WEIGHTS: num_weights = 3; break;
default:
FIXME("unsupported vertex blend render state: %u\n", state->render_states[WINED3D_RS_VERTEXBLEND]);
return (BYTE *)data;
}
switch (SI_FORMAT(element_idx))
{
case WINED3D_FFP_EMIT_FLOAT4: vector[3] = data[3];
case WINED3D_FFP_EMIT_FLOAT3: vector[2] = data[2];
case WINED3D_FFP_EMIT_FLOAT2: vector[1] = data[1];
case WINED3D_FFP_EMIT_FLOAT1: vector[0] = data[0]; break;
default:
FIXME("unsupported value format: %u\n", SI_FORMAT(element_idx));
return (BYTE *)data;
}
blend_index = SI_PTR(WINED3D_FFP_BLENDINDICES, stride_idx);
weights = (const float *)SI_PTR(WINED3D_FFP_BLENDWEIGHT, stride_idx);
result[0] = result[1] = result[2] = result[3] = 0.0f;
for (i = 0; i < num_weights + 1; i++)
{
cur_weight = (i < num_weights) ? weights[i] : 1.0f - weight_sum;
get_modelview_matrix(context, state, blend_index[i], &m);
if (element_idx == WINED3D_FFP_POSITION)
{
result[0] += cur_weight * (vector[0] * m._11 + vector[1] * m._21 + vector[2] * m._31 + vector[3] * m._41);
result[1] += cur_weight * (vector[0] * m._12 + vector[1] * m._22 + vector[2] * m._32 + vector[3] * m._42);
result[2] += cur_weight * (vector[0] * m._13 + vector[1] * m._23 + vector[2] * m._33 + vector[3] * m._43);
result[3] += cur_weight * (vector[0] * m._14 + vector[1] * m._24 + vector[2] * m._34 + vector[3] * m._44);
}
else
{
if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_FFP_LIGHTING)
invert_matrix_3d(&m, &m);
else
invert_matrix(&m, &m);
/* multiply with transposed M */
result[0] += cur_weight * (vector[0] * m._11 + vector[1] * m._12 + vector[2] * m._13);
result[1] += cur_weight * (vector[0] * m._21 + vector[1] * m._22 + vector[2] * m._23);
result[2] += cur_weight * (vector[0] * m._31 + vector[1] * m._32 + vector[2] * m._33);
}
weight_sum += weights[i];
}
#undef SI_FORMAT
#undef SI_PTR
return (BYTE *)result;
}
static unsigned int get_stride_idx(const void *idx_data, unsigned int idx_size,
unsigned int base_vertex_idx, unsigned int start_idx, unsigned int vertex_idx)
{
@ -317,7 +190,6 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const
BOOL specular_fog = FALSE;
BOOL ps = use_ps(state);
const void *ptr;
float tmp[4];
static unsigned int once;
@ -354,7 +226,7 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const
if (!(use_map & 1u << element_idx))
continue;
ptr = software_vertex_blending(context, state, si, element_idx, stride_idx, tmp);
ptr = si->elements[element_idx].data.addr + si->elements[element_idx].stride * stride_idx;
ops->generic[si->elements[element_idx].format->emit_idx](element_idx, ptr);
}
}
@ -466,7 +338,7 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const
if (normal)
{
ptr = software_vertex_blending(context, state, si, WINED3D_FFP_NORMAL, stride_idx, tmp);
ptr = normal + stride_idx * si->elements[WINED3D_FFP_NORMAL].stride;
ops->normal[si->elements[WINED3D_FFP_NORMAL].format->emit_idx](ptr);
}
@ -511,7 +383,7 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const
if (position)
{
ptr = software_vertex_blending(context, state, si, WINED3D_FFP_POSITION, stride_idx, tmp);
ptr = position + stride_idx * si->elements[WINED3D_FFP_POSITION].stride;
ops->position[si->elements[WINED3D_FFP_POSITION].format->emit_idx](ptr);
}
}
@ -520,6 +392,39 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const
checkGLcall("glEnd and previous calls");
}
static void draw_indirect(struct wined3d_context *context, const struct wined3d_state *state,
const struct wined3d_indirect_draw_parameters *parameters, unsigned int idx_size)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_buffer *buffer = parameters->buffer;
if (!gl_info->supported[ARB_DRAW_INDIRECT])
{
FIXME("OpenGL implementation does not support indirect draws.\n");
return;
}
GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer->buffer_object));
if (idx_size)
{
GLenum idx_type = idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
if (state->index_offset)
FIXME("Ignoring index offset %u.\n", state->index_offset);
GL_EXTCALL(glDrawElementsIndirect(state->gl_primitive_type, idx_type,
(void *)(GLintptr)parameters->offset));
}
else
{
GL_EXTCALL(glDrawArraysIndirect(state->gl_primitive_type,
(void *)(GLintptr)parameters->offset));
}
GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0));
checkGLcall("draw indirect");
}
static void remove_vbos(struct wined3d_context *context,
const struct wined3d_state *state, struct wined3d_stream_info *s)
{
@ -637,7 +542,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
if (!(rtv = fb->render_targets[i]) || rtv->format->id == WINED3DFMT_NULL)
continue;
if (state->render_states[WINED3D_RS_COLORWRITE(i)])
if (state->render_states[WINED3D_RS_COLORWRITEENABLE])
{
wined3d_rendertarget_view_load_location(rtv, context, rtv->resource->draw_binding);
wined3d_rendertarget_view_invalidate_location(rtv, ~rtv->resource->draw_binding);
@ -663,6 +568,9 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
wined3d_rendertarget_view_prepare_location(dsv, context, location);
}
if (parameters->indirect)
wined3d_buffer_load(parameters->u.indirect.buffer, context, state);
if (!context_apply_draw_state(context, device, state))
{
context_release(context);
@ -726,11 +634,6 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
WARN_(d3d_perf)("Using software emulation because manual fog coordinates are provided.\n");
emulation = TRUE;
}
else if (use_indexed_vertex_blending(state, stream_info) && use_software_vertex_processing(context->device))
{
WARN_(d3d_perf)("Using software emulation because application requested SVP.\n");
emulation = TRUE;
}
if (emulation)
{
@ -744,7 +647,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
{
const struct wined3d_shader *shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
if (shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM)
if (is_rasterization_disabled(shader))
{
glEnable(GL_RASTERIZER_DISCARD);
checkGLcall("enable rasterizer discard");
@ -774,11 +677,10 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
if (parameters->indirect)
{
if (context->use_immediate_mode_draw || emulation)
FIXME("Indirect draw with immediate mode/emulation is not supported.\n");
if (!context->use_immediate_mode_draw && !emulation)
draw_indirect(context, state, &parameters->u.indirect, idx_size);
else
draw_primitive_arrays_indirect(context, state, idx_data, idx_size,
parameters->u.indirect.buffer, parameters->u.indirect.offset);
FIXME("Indirect draws with immediate mode/emulation are not supported.\n");
}
else
{
@ -845,6 +747,9 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state
return;
}
if (parameters->indirect)
wined3d_buffer_load(parameters->u.indirect.buffer, context, state);
context_apply_compute_state(context, device, state);
if (!state->shader[WINED3D_SHADER_TYPE_COMPUTE])
@ -859,7 +764,6 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state
const struct wined3d_indirect_dispatch_parameters *indirect = &parameters->u.indirect;
struct wined3d_buffer *buffer = indirect->buffer;
wined3d_buffer_load(buffer, context, state);
GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, buffer->buffer_object));
GL_EXTCALL(glDispatchComputeIndirect((GLintptr)indirect->offset));
GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0));

File diff suppressed because it is too large Load diff

View file

@ -387,7 +387,7 @@ HRESULT CDECL wined3d_query_get_data(struct wined3d_query *query,
}
else if (query->counter_main != query->counter_retrieved)
{
if (flags & WINED3DGETDATA_FLUSH)
if (flags & WINED3DGETDATA_FLUSH && !query->device->cs->queries_flushed)
wined3d_cs_emit_flush(query->device->cs);
return S_FALSE;
}
@ -911,34 +911,6 @@ static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD
return poll;
}
static BOOL wined3d_statistics_query_ops_poll(struct wined3d_query *query, DWORD flags)
{
TRACE("query %p, flags %#x.\n", query, flags);
return TRUE;
}
static BOOL wined3d_statistics_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
FIXME("query %p, flags %#x.\n", query, flags);
return FALSE;
}
static BOOL wined3d_overflow_query_ops_poll(struct wined3d_query *query, DWORD flags)
{
TRACE("query %p, flags %#x.\n", query, flags);
return TRUE;
}
static BOOL wined3d_overflow_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
FIXME("query %p, flags %#x.\n", query, flags);
return FALSE;
}
static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
{
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
@ -1223,72 +1195,6 @@ static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device,
return WINED3D_OK;
}
static void wined3d_statistics_query_ops_destroy(struct wined3d_query *query)
{
HeapFree(GetProcessHeap(), 0, query);
}
static const struct wined3d_query_ops statistics_query_ops =
{
wined3d_statistics_query_ops_poll,
wined3d_statistics_query_ops_issue,
wined3d_statistics_query_ops_destroy,
};
static HRESULT wined3d_statistics_query_create(struct wined3d_device *device,
enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_query **query)
{
static const struct wined3d_query_data_so_statistics statistics = { 1, 1 };
struct wined3d_query *object;
FIXME("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_query_init(object, device, type, &statistics,
sizeof(statistics), &statistics_query_ops, parent, parent_ops);
TRACE("Created query %p.\n", object);
*query = object;
return WINED3D_OK;
}
static void wined3d_overflow_query_ops_destroy(struct wined3d_query *query)
{
HeapFree(GetProcessHeap(), 0, query);
}
static const struct wined3d_query_ops overflow_query_ops =
{
wined3d_overflow_query_ops_poll,
wined3d_overflow_query_ops_issue,
wined3d_overflow_query_ops_destroy,
};
static HRESULT wined3d_overflow_query_create(struct wined3d_device *device,
enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_query **query)
{
static const BOOL overflow = FALSE;
struct wined3d_query *object;
FIXME("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
wined3d_query_init(object, device, type, &overflow,
sizeof(overflow), &overflow_query_ops, parent, parent_ops);
TRACE("Created query %p.\n", object);
*query = object;
return WINED3D_OK;
}
HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_query_type type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
{
@ -1319,12 +1225,6 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_q
case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS:
return wined3d_pipeline_query_create(device, type, parent, parent_ops, query);
case WINED3D_QUERY_TYPE_SO_STATISTICS:
return wined3d_statistics_query_create(device, type, parent, parent_ops, query);
case WINED3D_QUERY_TYPE_SO_OVERFLOW:
return wined3d_overflow_query_create(device, type, parent, parent_ops, query);
default:
FIXME("Unhandled query type %#x.\n", type);
return WINED3DERR_NOTAVAILABLE;

View file

@ -48,7 +48,7 @@ static DWORD resource_access_from_pool(enum wined3d_pool pool)
static void resource_check_usage(DWORD usage)
{
static DWORD handled = WINED3DUSAGE_RENDERTARGET
static const DWORD handled = WINED3DUSAGE_RENDERTARGET
| WINED3DUSAGE_DEPTHSTENCIL
| WINED3DUSAGE_WRITEONLY
| WINED3DUSAGE_DYNAMIC
@ -66,10 +66,7 @@ static void resource_check_usage(DWORD usage)
* driver. */
if (usage & ~handled)
{
FIXME("Unhandled usage flags %#x.\n", usage & ~handled);
handled |= usage;
}
if ((usage & (WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY)) == WINED3DUSAGE_DYNAMIC)
WARN_(d3d_perf)("WINED3DUSAGE_DYNAMIC used without WINED3DUSAGE_WRITEONLY.\n");
}
@ -96,7 +93,6 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource_types[] =
{
{WINED3D_RTYPE_BUFFER, 0, WINED3D_GL_RES_TYPE_BUFFER},
{WINED3D_RTYPE_TEXTURE_1D, 0, WINED3D_GL_RES_TYPE_TEX_1D},
{WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_TEX_2D},
{WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_TEX_RECT},
{WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_RB},
@ -337,17 +333,19 @@ static DWORD wined3d_resource_sanitise_map_flags(const struct wined3d_resource *
return 0;
}
}
else if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
== (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
{
WARN("WINED3D_MAP_DISCARD and WINED3D_MAP_NOOVERWRITE used together, ignoring.\n");
return 0;
}
else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)
&& !(resource->usage & WINED3DUSAGE_DYNAMIC))
{
WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n");
return 0;
if (!(resource->usage & WINED3DUSAGE_DYNAMIC))
{
WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n");
return 0;
}
if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
== (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
{
WARN("WINED3D_MAP_NOOVERWRITE used with WINED3D_MAP_DISCARD, ignoring WINED3D_MAP_DISCARD.\n");
flags &= ~WINED3D_MAP_DISCARD;
}
}
return flags;
@ -365,14 +363,6 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i
return wined3d_cs_map(resource->device->cs, resource, sub_resource_idx, map_desc, box, flags);
}
HRESULT CDECL wined3d_resource_map_info(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_info *info, DWORD flags)
{
TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
return resource->resource_ops->resource_map_info(resource, sub_resource_idx, info, flags);
}
HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
@ -380,99 +370,6 @@ HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned
return wined3d_cs_unmap(resource->device->cs, resource, sub_resource_idx);
}
UINT CDECL wined3d_resource_update_info(struct wined3d_resource *resource, unsigned int sub_resource_idx,
const struct wined3d_box *box, unsigned int row_pitch, unsigned int depth_pitch)
{
unsigned int width, height, depth;
struct wined3d_box b;
UINT data_size;
TRACE("resource %p, sub_resource_idx %u, box %s, row_pitch %u, depth_pitch %u.\n",
resource, sub_resource_idx, debug_box(box), row_pitch, depth_pitch);
if (resource->type == WINED3D_RTYPE_BUFFER)
{
if (sub_resource_idx > 0)
{
WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
return 0;
}
width = resource->size;
height = 1;
depth = 1;
}
else if (resource->type == WINED3D_RTYPE_TEXTURE_1D ||
resource->type == WINED3D_RTYPE_TEXTURE_2D || resource->type == WINED3D_RTYPE_TEXTURE_3D)
{
struct wined3d_texture *texture = texture_from_resource(resource);
unsigned int level;
if (sub_resource_idx >= texture->level_count * texture->layer_count)
{
WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
return 0;
}
level = sub_resource_idx % texture->level_count;
width = wined3d_texture_get_level_width(texture, level);
height = wined3d_texture_get_level_height(texture, level);
depth = wined3d_texture_get_level_depth(texture, level);
}
else
{
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
return 0;
}
if (!box)
{
wined3d_box_set(&b, 0, 0, width, height, 0, depth);
box = &b;
}
else if (box->left >= box->right || box->right > width
|| box->top >= box->bottom || box->bottom > height
|| box->front >= box->back || box->back > depth)
{
WARN("Invalid box %s specified.\n", debug_box(box));
return 0;
}
if (resource->format_flags & WINED3DFMT_FLAG_BLOCKS)
{
if (resource->type != WINED3D_RTYPE_TEXTURE_2D)
{
FIXME("Calculation of block formats not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
return 0;
}
height = (box->bottom - box->top + resource->format->block_height - 1) / resource->format->block_height;
width = (box->right - box->left + resource->format->block_width - 1) / resource->format->block_width;
return (height - 1) * row_pitch + width * resource->format->block_byte_count;
}
data_size = 0;
switch (resource->type)
{
case WINED3D_RTYPE_TEXTURE_3D:
data_size += (box->back - box->front - 1) * depth_pitch;
/* fall-through */
case WINED3D_RTYPE_TEXTURE_2D:
data_size += (box->bottom - box->top - 1) * row_pitch;
/* fall-through */
case WINED3D_RTYPE_TEXTURE_1D:
data_size += (box->right - box->left) * resource->format->byte_count;
break;
case WINED3D_RTYPE_BUFFER:
data_size = box->right - box->left;
break;
case WINED3D_RTYPE_NONE:
break;
}
return data_size;
}
void CDECL wined3d_resource_preload(struct wined3d_resource *resource)
{
wined3d_cs_emit_preload_resource(resource->device->cs, resource);

View file

@ -95,8 +95,8 @@ static void wined3d_sampler_cs_init(void *object)
GL_EXTCALL(glSamplerParameterf(sampler->name, GL_TEXTURE_LOD_BIAS, desc->lod_bias));
GL_EXTCALL(glSamplerParameterf(sampler->name, GL_TEXTURE_MIN_LOD, desc->min_lod));
GL_EXTCALL(glSamplerParameterf(sampler->name, GL_TEXTURE_MAX_LOD, desc->max_lod));
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
GL_EXTCALL(glSamplerParameteri(sampler->name, GL_TEXTURE_MAX_ANISOTROPY_EXT, desc->max_anisotropy));
if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
GL_EXTCALL(glSamplerParameteri(sampler->name, GL_TEXTURE_MAX_ANISOTROPY, desc->max_anisotropy));
if (desc->compare)
GL_EXTCALL(glSamplerParameteri(sampler->name, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE));
GL_EXTCALL(glSamplerParameteri(sampler->name, GL_TEXTURE_COMPARE_FUNC,

View file

@ -119,6 +119,7 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_DSY */ "dsy",
/* WINED3DSIH_DSY_COARSE */ "deriv_rty_coarse",
/* WINED3DSIH_DSY_FINE */ "deriv_rty_fine",
/* WINED3DSIH_EVAL_SAMPLE_INDEX */ "eval_sample_index",
/* WINED3DSIH_ELSE */ "else",
/* WINED3DSIH_EMIT */ "emit",
/* WINED3DSIH_EMIT_STREAM */ "emit_stream",
@ -686,14 +687,6 @@ static void shader_set_limits(struct wined3d_shader *shader)
}
}
static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit)
{
DWORD idx, shift;
idx = bit >> 5;
shift = bit & 0x1f;
bitmap[idx] |= (1u << shift);
}
static BOOL shader_record_register_usage(struct wined3d_shader *shader, struct wined3d_shader_reg_maps *reg_maps,
const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type, unsigned int constf_size)
{
@ -711,6 +704,8 @@ static BOOL shader_record_register_usage(struct wined3d_shader *shader, struct w
break;
case WINED3DSPR_INPUT:
if (reg->idx[0].rel_addr)
reg_maps->input_rel_addressing = 1;
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
{
/* If relative addressing is used, we must assume that all
@ -723,7 +718,9 @@ static BOOL shader_record_register_usage(struct wined3d_shader *shader, struct w
shader->u.ps.input_reg_used |= 1u << reg->idx[0].offset;
}
else
{
reg_maps->input_registers |= 1u << reg->idx[0].offset;
}
break;
case WINED3DSPR_RASTOUT:
@ -761,7 +758,7 @@ static BOOL shader_record_register_usage(struct wined3d_shader *shader, struct w
}
else
{
set_bitmap_bit(reg_maps->constf, reg->idx[0].offset);
wined3d_insert_bits(reg_maps->constf, reg->idx[0].offset, 1, 0x1);
}
}
break;
@ -954,6 +951,41 @@ static HRESULT shader_record_shader_phase(struct wined3d_shader *shader,
return WINED3D_OK;
}
static HRESULT shader_calculate_clip_or_cull_distance_mask(
const struct wined3d_shader_signature_element *e, DWORD *mask)
{
unsigned int i;
*mask = 0;
/* Cull and clip distances are packed in 4 component registers. 0 and 1 are
* the only allowed semantic indices.
*/
if (e->semantic_idx >= MAX_CLIP_DISTANCES / 4)
{
WARN("Invalid clip/cull distance index %u.\n", e->semantic_idx);
return WINED3DERR_INVALIDCALL;
}
for (i = 0; i < 4; ++i)
{
if (e->mask & (WINED3DSP_WRITEMASK_0 << i))
*mask |= 1u << (4 * e->semantic_idx + i);
}
return WINED3D_OK;
}
static void wined3d_insert_interpolation_mode(DWORD *packed_interpolation_mode,
unsigned int register_idx, enum wined3d_shader_interpolation_mode mode)
{
if (mode > WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE)
FIXME("Unexpected interpolation mode %#x.\n", mode);
wined3d_insert_bits(packed_interpolation_mode,
register_idx * WINED3D_PACKED_INTERPOLATION_BIT_COUNT, WINED3D_PACKED_INTERPOLATION_BIT_COUNT, mode);
}
/* Note that this does not count the loop register as an address register. */
static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const struct wined3d_shader_frontend *fe,
struct wined3d_shader_reg_maps *reg_maps, struct wined3d_shader_signature *input_signature,
@ -1141,15 +1173,31 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
FIXME("Invalid instruction %#x for shader type %#x.\n",
ins.handler_idx, shader_version.type);
}
else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS)
{
unsigned int reg_idx = ins.declaration.dst.reg.idx[0].offset;
if (reg_idx >= MAX_REG_INPUT)
{
ERR("Invalid register index %u.\n", reg_idx);
break;
}
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
wined3d_insert_interpolation_mode(shader->u.ps.interpolation_mode, reg_idx, ins.flags);
else
FIXME("Invalid instruction %#x for shader type %#x.\n",
ins.handler_idx, shader_version.type);
}
else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT)
{
if (ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUT_GREATER_EQUAL ||
ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUT_LESS_EQUAL)
if (ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUT
|| ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUTGE
|| ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUTLE)
{
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
shader->u.ps.depth_compare = ins.declaration.dst.reg.type;
shader->u.ps.depth_output = ins.declaration.dst.reg.type;
else
FIXME("Invalid instruction depth declaration for shader type %#x.\n", shader_version.type);
FIXME("Invalid instruction %#x for shader type %#x.\n",
ins.handler_idx, shader_version.type);
}
}
else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT)
@ -1730,7 +1778,22 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
{
for (i = 0; i < output_signature->element_count; ++i)
{
reg_maps->output_registers |= 1u << output_signature->elements[i].register_idx;
const struct wined3d_shader_signature_element *e = &output_signature->elements[i];
DWORD mask;
reg_maps->output_registers |= 1u << e->register_idx;
if (e->sysval_semantic == WINED3D_SV_CLIP_DISTANCE)
{
if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask)))
return hr;
reg_maps->clip_distance_mask |= mask;
}
else if (e->sysval_semantic == WINED3D_SV_CULL_DISTANCE)
{
if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask)))
return hr;
reg_maps->cull_distance_mask |= mask;
}
}
}
else if (reg_maps->output_registers)
@ -2143,18 +2206,18 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer,
shader_addline(buffer, "oC");
break;
case WINED3DSPR_DEPTHOUT_GREATER_EQUAL:
shader_addline(buffer, "oDepth_greater_equal");
break;
case WINED3DSPR_DEPTHOUT_LESS_EQUAL:
shader_addline(buffer, "oDepth_less_equal");
break;
case WINED3DSPR_DEPTHOUT:
shader_addline(buffer, "oDepth");
break;
case WINED3DSPR_DEPTHOUTGE:
shader_addline(buffer, "oDepthGE");
break;
case WINED3DSPR_DEPTHOUTLE:
shader_addline(buffer, "oDepthLE");
break;
case WINED3DSPR_ATTROUT:
shader_addline(buffer, "oD");
break;
@ -2934,7 +2997,8 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe
if (ins.handler_idx == WINED3DSIH_BREAKP
|| ins.handler_idx == WINED3DSIH_CONTINUEP
|| ins.handler_idx == WINED3DSIH_IF
|| ins.handler_idx == WINED3DSIH_RETP)
|| ins.handler_idx == WINED3DSIH_RETP
|| ins.handler_idx == WINED3DSIH_TEXKILL)
{
switch (ins.flags)
{
@ -3377,25 +3441,41 @@ HRESULT CDECL wined3d_shader_set_local_constants_float(struct wined3d_shader *sh
return WINED3D_OK;
}
void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
WORD swizzle_map, struct vs_compile_args *args, const struct wined3d_d3d_info *d3d_info)
static void init_interpolation_compile_args(DWORD *interpolation_args,
const struct wined3d_shader *pixel_shader, const struct wined3d_gl_info *gl_info)
{
if (!needs_interpolation_qualifiers_for_shader_outputs(gl_info)
|| !pixel_shader || pixel_shader->reg_maps.shader_version.major < 4)
{
memset(interpolation_args, 0, sizeof(pixel_shader->u.ps.interpolation_mode));
return;
}
memcpy(interpolation_args, pixel_shader->u.ps.interpolation_mode,
sizeof(pixel_shader->u.ps.interpolation_mode));
}
void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
WORD swizzle_map, struct vs_compile_args *args, const struct wined3d_context *context)
{
const struct wined3d_shader *geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
const struct wined3d_gl_info *gl_info = context->gl_info;
args->fog_src = state->render_states[WINED3D_RS_FOGTABLEMODE]
== WINED3D_FOG_NONE ? VS_FOG_COORD : VS_FOG_Z;
args->clip_enabled = state->render_states[WINED3D_RS_CLIPPING]
&& state->render_states[WINED3D_RS_CLIPPLANEENABLE];
args->point_size = state->gl_primitive_type == GL_POINTS;
args->per_vertex_point_size = shader->reg_maps.point_size;
args->next_shader_type = state->shader[WINED3D_SHADER_TYPE_HULL] ? WINED3D_SHADER_TYPE_HULL
: state->shader[WINED3D_SHADER_TYPE_GEOMETRY] ? WINED3D_SHADER_TYPE_GEOMETRY
: WINED3D_SHADER_TYPE_PIXEL;
args->next_shader_type = hull_shader? WINED3D_SHADER_TYPE_HULL
: geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL;
if (shader->reg_maps.shader_version.major >= 4)
args->next_shader_input_count = state->shader[WINED3D_SHADER_TYPE_HULL]
? state->shader[WINED3D_SHADER_TYPE_HULL]->limits->packed_input
: state->shader[WINED3D_SHADER_TYPE_GEOMETRY]
? state->shader[WINED3D_SHADER_TYPE_GEOMETRY]->limits->packed_input
: state->shader[WINED3D_SHADER_TYPE_PIXEL]
? state->shader[WINED3D_SHADER_TYPE_PIXEL]->limits->packed_input : 0;
args->next_shader_input_count = hull_shader ? hull_shader->limits->packed_input
: geometry_shader ? geometry_shader->limits->packed_input
: pixel_shader ? pixel_shader->limits->packed_input : 0;
else
args->next_shader_input_count = 0;
args->swizzle_map = swizzle_map;
@ -3403,6 +3483,9 @@ void find_vs_compile_args(const struct wined3d_state *state, const struct wined3
args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
else
args->flatshading = 0;
init_interpolation_compile_args(args->interpolation_mode,
args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, gl_info);
}
static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2)
@ -3631,18 +3714,6 @@ static HRESULT vertex_shader_init(struct wined3d_shader *shader, struct wined3d_
return WINED3D_OK;
}
static HRESULT domain_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
{
return shader_init(shader, device, desc, 0, WINED3D_SHADER_TYPE_DOMAIN, parent, parent_ops);
}
static HRESULT hull_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
{
return shader_init(shader, device, desc, 0, WINED3D_SHADER_TYPE_HULL, parent, parent_ops);
}
static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const struct wined3d_shader_desc *desc, const struct wined3d_stream_output_desc *so_desc,
void *parent, const struct wined3d_parent_ops *parent_ops)
@ -3672,28 +3743,35 @@ static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3
void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
struct ds_compile_args *args, const struct wined3d_context *context)
{
const struct wined3d_shader *geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
const struct wined3d_gl_info *gl_info = context->gl_info;
args->tessellator_output_primitive = hull_shader->u.hs.tessellator_output_primitive;
args->tessellator_partitioning = hull_shader->u.hs.tessellator_partitioning;
args->output_count = state->shader[WINED3D_SHADER_TYPE_GEOMETRY] ?
state->shader[WINED3D_SHADER_TYPE_GEOMETRY]->limits->packed_input :
state->shader[WINED3D_SHADER_TYPE_PIXEL] ? state->shader[WINED3D_SHADER_TYPE_PIXEL]->limits->packed_input
: shader->limits->packed_output;
args->next_shader_type = state->shader[WINED3D_SHADER_TYPE_GEOMETRY] ? WINED3D_SHADER_TYPE_GEOMETRY
: WINED3D_SHADER_TYPE_PIXEL;
args->output_count = geometry_shader ? geometry_shader->limits->packed_input
: pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output;
args->next_shader_type = geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL;
args->render_offscreen = context->render_offscreen;
init_interpolation_compile_args(args->interpolation_mode,
args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, gl_info);
args->padding = 0;
}
void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
struct gs_compile_args *args)
struct gs_compile_args *args, const struct wined3d_context *context)
{
args->output_count = state->shader[WINED3D_SHADER_TYPE_PIXEL]
? state->shader[WINED3D_SHADER_TYPE_PIXEL]->limits->packed_input : shader->limits->packed_output;
const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
const struct wined3d_gl_info *gl_info = context->gl_info;
args->output_count = pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output;
init_interpolation_compile_args(args->interpolation_mode, pixel_shader, gl_info);
}
void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
@ -3928,8 +4006,6 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
args->render_offscreen = shader->reg_maps.vpos && gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]
? context->render_offscreen : 0;
args->dual_source_blend = wined3d_dualblend_enabled(state, gl_info);
}
static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
@ -4018,12 +4094,6 @@ void pixelshader_update_resource_types(struct wined3d_shader *shader, WORD tex_t
}
}
static HRESULT compute_shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
{
return shader_init(shader, device, desc, 0, WINED3D_SHADER_TYPE_COMPUTE, parent, parent_ops);
}
HRESULT CDECL wined3d_shader_create_cs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
{
@ -4036,7 +4106,7 @@ HRESULT CDECL wined3d_shader_create_cs(struct wined3d_device *device, const stru
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = compute_shader_init(object, device, desc, parent, parent_ops)))
if (FAILED(hr = shader_init(object, device, desc, 0, WINED3D_SHADER_TYPE_COMPUTE, parent, parent_ops)))
{
WARN("Failed to initialize compute shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
@ -4061,7 +4131,7 @@ HRESULT CDECL wined3d_shader_create_ds(struct wined3d_device *device, const stru
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = domain_shader_init(object, device, desc, parent, parent_ops)))
if (FAILED(hr = shader_init(object, device, desc, 0, WINED3D_SHADER_TYPE_DOMAIN, parent, parent_ops)))
{
WARN("Failed to initialize domain shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
@ -4112,7 +4182,7 @@ HRESULT CDECL wined3d_shader_create_hs(struct wined3d_device *device, const stru
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = hull_shader_init(object, device, desc, parent, parent_ops)))
if (FAILED(hr = shader_init(object, device, desc, 0, WINED3D_SHADER_TYPE_HULL, parent, parent_ops)))
{
WARN("Failed to initialize hull shader, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);

View file

@ -294,6 +294,7 @@ enum wined3d_sm4_opcode
WINED3D_SM5_OP_IMM_ATOMIC_UMAX = 0xbc,
WINED3D_SM5_OP_IMM_ATOMIC_UMIN = 0xbd,
WINED3D_SM5_OP_SYNC = 0xbe,
WINED3D_SM5_OP_EVAL_SAMPLE_INDEX = 0xcc,
WINED3D_SM5_OP_DCL_GS_INSTANCES = 0xce,
};
@ -337,7 +338,7 @@ enum wined3d_sm4_register_type
enum wined3d_sm4_output_primitive_type
{
WINED3D_SM4_OUTPUT_PT_POINTLIST = 0x1,
WINED3D_SM4_OUTPUT_PT_LINELIST = 0x3,
WINED3D_SM4_OUTPUT_PT_LINESTRIP = 0x3,
WINED3D_SM4_OUTPUT_PT_TRIANGLESTRIP = 0x5,
};
@ -466,7 +467,7 @@ static const enum wined3d_primitive_type output_primitive_type_table[] =
/* UNKNOWN */ WINED3D_PT_UNDEFINED,
/* WINED3D_SM4_OUTPUT_PT_POINTLIST */ WINED3D_PT_POINTLIST,
/* UNKNOWN */ WINED3D_PT_UNDEFINED,
/* WINED3D_SM4_OUTPUT_PT_LINELIST */ WINED3D_PT_LINELIST,
/* WINED3D_SM4_OUTPUT_PT_LINESTRIP */ WINED3D_PT_LINESTRIP,
/* UNKNOWN */ WINED3D_PT_UNDEFINED,
/* WINED3D_SM4_OUTPUT_PT_TRIANGLESTRIP */ WINED3D_PT_TRIANGLESTRIP,
};
@ -891,7 +892,8 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
{WINED3D_SM4_OP_DEFAULT, WINED3DSIH_DEFAULT, "", ""},
{WINED3D_SM4_OP_DERIV_RTX, WINED3DSIH_DSX, "f", "f"},
{WINED3D_SM4_OP_DERIV_RTY, WINED3DSIH_DSY, "f", "f"},
{WINED3D_SM4_OP_DISCARD, WINED3DSIH_TEXKILL, "", "u"},
{WINED3D_SM4_OP_DISCARD, WINED3DSIH_TEXKILL, "", "u",
shader_sm4_read_conditional_op},
{WINED3D_SM4_OP_DIV, WINED3DSIH_DIV, "f", "ff"},
{WINED3D_SM4_OP_DP2, WINED3DSIH_DP2, "f", "ff"},
{WINED3D_SM4_OP_DP3, WINED3DSIH_DP3, "f", "ff"},
@ -1103,6 +1105,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
{WINED3D_SM5_OP_IMM_ATOMIC_UMIN, WINED3DSIH_IMM_ATOMIC_UMIN, "uU", "iu"},
{WINED3D_SM5_OP_SYNC, WINED3DSIH_SYNC, "", "",
shader_sm5_read_sync},
{WINED3D_SM5_OP_EVAL_SAMPLE_INDEX, WINED3DSIH_EVAL_SAMPLE_INDEX, "f", "fi"},
{WINED3D_SM5_OP_DCL_GS_INSTANCES, WINED3DSIH_DCL_GS_INSTANCES, "", "",
shader_sm4_read_declaration_count},
};
@ -1147,15 +1150,15 @@ static const enum wined3d_shader_register_type register_type_table[] =
/* WINED3D_SM5_RT_COVERAGE */ WINED3DSPR_COVERAGE,
/* WINED3D_SM5_RT_LOCAL_THREAD_INDEX */ WINED3DSPR_LOCALTHREADINDEX,
/* WINED3D_SM5_RT_GS_INSTANCE_ID */ WINED3DSPR_GSINSTID,
/* WINED3D_SM5_RT_DEPTHOUT_GREATER_EQUAL */ WINED3DSPR_DEPTHOUT_GREATER_EQUAL,
/* WINED3D_SM5_RT_DEPTHOUT_LESS_EQUAL*/ WINED3DSPR_DEPTHOUT_LESS_EQUAL,
/* WINED3D_SM5_RT_DEPTHOUT_GREATER_EQUAL */ WINED3DSPR_DEPTHOUTGE,
/* WINED3D_SM5_RT_DEPTHOUT_LESS_EQUAL */ WINED3DSPR_DEPTHOUTLE,
};
static const struct wined3d_sm4_opcode_info *get_opcode_info(enum wined3d_sm4_opcode opcode)
{
unsigned int i;
for (i = 0; i < sizeof(opcode_table) / sizeof(*opcode_table); ++i)
for (i = 0; i < ARRAY_SIZE(opcode_table); ++i)
{
if (opcode == opcode_table[i].opcode) return &opcode_table[i];
}
@ -1383,7 +1386,7 @@ static BOOL shader_sm4_read_param(struct wined3d_sm4_data *priv, const DWORD **p
token = *(*ptr)++;
register_type = (token & WINED3D_SM4_REGISTER_TYPE_MASK) >> WINED3D_SM4_REGISTER_TYPE_SHIFT;
if (register_type >= sizeof(register_type_table) / sizeof(*register_type_table)
if (register_type >= ARRAY_SIZE(register_type_table)
|| register_type_table[register_type] == ~0u)
{
FIXME("Unhandled register type %#x.\n", register_type);

View file

@ -464,13 +464,10 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st
const struct wined3d_format *rt_format;
GLenum src_blend, dst_blend;
unsigned int rt_fmt_flags;
BOOL enable_dual_blend;
BOOL enable_blend;
enable_blend = state->fb->render_targets[0] && state->render_states[WINED3D_RS_ALPHABLENDENABLE];
enable_dual_blend = wined3d_dualblend_enabled(state, context->gl_info);
if (enable_blend && !enable_dual_blend)
if (enable_blend)
{
rt_format = state->fb->render_targets[0]->format;
rt_fmt_flags = state->fb->render_targets[0]->format_flags;
@ -482,13 +479,6 @@ static void state_blend(struct wined3d_context *context, const struct wined3d_st
enable_blend = FALSE;
}
/* Dual state blending changes the assignment of the output variables */
if (context->last_was_dual_blend != enable_dual_blend)
{
context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL;
context->last_was_dual_blend = enable_dual_blend;
}
if (!enable_blend)
{
gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
@ -613,9 +603,7 @@ void state_alpha_test(struct wined3d_context *context, const struct wined3d_stat
void state_clipping(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int clipplane_count = gl_info->limits.user_clip_distances;
unsigned int i, enable_mask, disable_mask;
unsigned int enable_mask;
if (use_vs(state) && !context->d3d_info->vs_clipping)
{
@ -628,7 +616,7 @@ void state_clipping(struct wined3d_context *context, const struct wined3d_state
* disables all clip planes because of that - don't do anything here
* and keep them disabled. */
if (state->render_states[WINED3D_RS_CLIPPLANEENABLE] && !warned++)
FIXME("Clipping not supported with vertex shaders\n");
FIXME("Clipping not supported with vertex shaders.\n");
return;
}
@ -638,39 +626,12 @@ void state_clipping(struct wined3d_context *context, const struct wined3d_state
* need to update the clipping field from ffp_vertex_settings. */
context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_VERTEX;
/* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
* of already set values
*/
/* If enabling / disabling all
* TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
*/
if (state->render_states[WINED3D_RS_CLIPPING])
{
enable_mask = state->render_states[WINED3D_RS_CLIPPLANEENABLE];
disable_mask = ~state->render_states[WINED3D_RS_CLIPPLANEENABLE];
}
else
{
enable_mask = 0;
disable_mask = ~0u;
}
if (clipplane_count < 32)
{
enable_mask &= (1u << clipplane_count) - 1;
disable_mask &= (1u << clipplane_count) - 1;
}
for (i = 0; enable_mask && i < clipplane_count; enable_mask >>= 1, ++i)
if (enable_mask & 1)
gl_info->gl_ops.gl.p_glEnable(GL_CLIP_DISTANCE0 + i);
checkGLcall("clip plane enable");
for (i = 0; disable_mask && i < clipplane_count; disable_mask >>= 1, ++i)
if (disable_mask & 1)
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_DISTANCE0 + i);
checkGLcall("clip plane disable");
enable_mask = state->render_states[WINED3D_RS_CLIPPING] ?
state->render_states[WINED3D_RS_CLIPPLANEENABLE] : 0;
context_enable_clip_distances(context, enable_mask);
}
static void state_specularenable(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
@ -1503,6 +1464,9 @@ static void state_debug_monitor(struct wined3d_context *context, const struct wi
static void state_colorwrite(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
DWORD mask0 = state->render_states[WINED3D_RS_COLORWRITEENABLE];
DWORD mask1 = state->render_states[WINED3D_RS_COLORWRITEENABLE1];
DWORD mask2 = state->render_states[WINED3D_RS_COLORWRITEENABLE2];
DWORD mask3 = state->render_states[WINED3D_RS_COLORWRITEENABLE3];
const struct wined3d_gl_info *gl_info = context->gl_info;
TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
@ -1516,7 +1480,13 @@ static void state_colorwrite(struct wined3d_context *context, const struct wined
mask0 & WINED3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
checkGLcall("glColorMask(...)");
/* FIXME: WINED3D_RS_COLORWRITEENABLE1 .. WINED3D_RS_COLORWRITEENABLE7 not implemented. */
if (!((mask1 == mask0 && mask2 == mask0 && mask3 == mask0)
|| (mask1 == 0xf && mask2 == 0xf && mask3 == 0xf)))
{
FIXME("WINED3D_RS_COLORWRITEENABLE/1/2/3, %#x/%#x/%#x/%#x not yet implemented.\n",
mask0, mask1, mask2, mask3);
FIXME("Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n");
}
}
static void set_color_mask(const struct wined3d_gl_info *gl_info, UINT index, DWORD mask)
@ -1529,20 +1499,24 @@ static void set_color_mask(const struct wined3d_gl_info *gl_info, UINT index, DW
checkGLcall("glColorMaski");
}
static void state_colorwrite_i(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
static void state_colorwrite0(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
int index;
set_color_mask(context->gl_info, 0, state->render_states[WINED3D_RS_COLORWRITEENABLE]);
}
if (state_id == WINED3D_RS_COLORWRITEENABLE) index = 0;
else if (state_id <= WINED3D_RS_COLORWRITEENABLE3) index = state_id - WINED3D_RS_COLORWRITEENABLE1 + 1;
else if (state_id <= WINED3D_RS_COLORWRITEENABLE7) index = state_id - WINED3D_RS_COLORWRITEENABLE4 + 4;
else return;
static void state_colorwrite1(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
set_color_mask(context->gl_info, 1, state->render_states[WINED3D_RS_COLORWRITEENABLE1]);
}
if (index >= gl_info->limits.buffers)
WARN("Ignoring color write value for index %d, because gpu only supports %d render targets\n", index, gl_info->limits.buffers);
static void state_colorwrite2(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
set_color_mask(context->gl_info, 2, state->render_states[WINED3D_RS_COLORWRITEENABLE2]);
}
set_color_mask(context->gl_info, index, state->render_states[state_id]);
static void state_colorwrite3(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
set_color_mask(context->gl_info, 3, state->render_states[WINED3D_RS_COLORWRITEENABLE3]);
}
static void state_localviewer(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
@ -1710,82 +1684,50 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
|| state->render_states[WINED3D_RS_DEPTHBIAS])
{
const struct wined3d_rendertarget_view *depth = state->fb->depth_stencil;
float scale;
float factor, units, scale;
union
{
DWORD d;
INT i;
float f;
} scale_bias, const_bias;
scale_bias.d = state->render_states[WINED3D_RS_SLOPESCALEDEPTHBIAS];
const_bias.d = state->render_states[WINED3D_RS_DEPTHBIAS];
gl_info->gl_ops.gl.p_glEnable(GL_POLYGON_OFFSET_FILL);
checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_DEPTH_BIAS)
{
float bias = -(float)const_bias.d;
gl_info->gl_ops.gl.p_glPolygonOffset(bias, bias);
checkGLcall("glPolygonOffset");
}
else if (context->d3d_info->wined3d_creation_flags & WINED3D_FORWARD_DEPTH_BIAS)
{
gl_info->gl_ops.gl.p_glPolygonOffset(scale_bias.f, const_bias.i);
checkGLcall("glPolygonOffset(...)");
factor = units = -(float)const_bias.d;
}
else
{
if (depth)
{
if (depth->format_flags & WINED3DFMT_FLAG_FLOAT)
scale = gl_info->float_polyoffset_scale;
else
scale = gl_info->fixed_polyoffset_scale;
scale = depth->format->depth_bias_scale;
TRACE("Depth format %s, using depthbias scale of %.8e.\n",
debug_d3dformat(depth->format->id), scale);
debug_d3dformat(depth->format->id), scale);
}
else
{
/* The context manager will reapply this state on a depth stencil change */
TRACE("No depth stencil, using depthbias scale of 0.0.\n");
TRACE("No depth stencil, using depth bias scale of 0.0.\n");
scale = 0.0f;
}
gl_info->gl_ops.gl.p_glPolygonOffset(scale_bias.f, const_bias.f * scale);
checkGLcall("glPolygonOffset(...)");
factor = scale_bias.f;
units = const_bias.f * scale;
}
gl_info->gl_ops.gl.p_glEnable(GL_POLYGON_OFFSET_FILL);
gl_info->gl_ops.gl.p_glPolygonOffset(factor, units);
}
else
{
gl_info->gl_ops.gl.p_glDisable(GL_POLYGON_OFFSET_FILL);
checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
}
}
static void state_depthclip(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
if (state->render_states[WINED3D_RS_DEPTHCLIP])
{
gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_CLAMP);
checkGLcall("glDisable(GL_DEPTH_CLAMP)");
}
else
{
gl_info->gl_ops.gl.p_glEnable(GL_DEPTH_CLAMP);
checkGLcall("glEnable(GL_DEPTH_CLAMP)");
}
}
static void state_depthclip_w(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
if (!state->render_states[WINED3D_RS_DEPTHCLIP])
FIXME("Depth clamping not supported by GL.\n");
checkGLcall("depth bias");
}
static void state_zvisible(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
@ -4552,22 +4494,19 @@ static void vertexdeclaration(struct wined3d_context *context, const struct wine
}
else
{
if(!context->last_was_vshader) {
if (!context->last_was_vshader)
{
static BOOL warned = FALSE;
if (!context->d3d_info->vs_clipping)
{
/* Disable all clip planes to get defined results on all drivers. See comment in the
* state_clipping state handler
*/
for (i = 0; i < gl_info->limits.user_clip_distances; ++i)
{
gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE0 + i);
checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
}
context_enable_clip_distances(context, 0);
if (!warned && state->render_states[WINED3D_RS_CLIPPLANEENABLE])
{
FIXME("Clipping not supported with vertex shaders\n");
FIXME("Clipping not supported with vertex shaders.\n");
warned = TRUE;
}
}
@ -4631,13 +4570,11 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
if (target)
{
if (context->d3d_info->wined3d_creation_flags & WINED3D_LIMIT_VIEWPORT)
{
if (vp.width > target->width)
vp.width = target->width;
if (vp.height > target->height)
vp.height = target->height;
}
if (vp.width > target->width)
vp.width = target->width;
if (vp.height > target->height)
vp.height = target->height;
wined3d_rendertarget_view_get_drawable_size(target, context, &width, &height);
}
else if (depth_stencil)
@ -4679,13 +4616,10 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
if (target)
{
if (context->d3d_info->wined3d_creation_flags & WINED3D_LIMIT_VIEWPORT)
{
if (vp.width > target->width)
vp.width = target->width;
if (vp.height > target->height)
vp.height = target->height;
}
if (vp.width > target->width)
vp.width = target->width;
if (vp.height > target->height)
vp.height = target->height;
wined3d_rendertarget_view_get_drawable_size(target, context, &width, &height);
}
@ -5220,32 +5154,22 @@ const struct StateEntryTemplate misc_state_template[] =
{ STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS), state_msaa_w }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK), { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK), state_multisampmask }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN), { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN), state_debug_monitor }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), state_colorwrite_i }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), state_colorwrite0 }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), state_colorwrite }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), state_colorwrite_i }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), state_colorwrite_i }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), state_colorwrite_i }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE4), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE4), state_colorwrite_i }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE4), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE5), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE5), state_colorwrite_i }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE5), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE6), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE6), state_colorwrite_i }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE6), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE7), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE7), state_colorwrite_i }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE7), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_BLENDOP), { STATE_RENDER(WINED3D_RS_BLENDOP), state_blendop }, WINED3D_GL_BLEND_EQUATION },
{ STATE_RENDER(WINED3D_RS_BLENDOP), { STATE_RENDER(WINED3D_RS_BLENDOP), state_blendop_w }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE), { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE), state_scissor }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_SLOPESCALEDEPTHBIAS), { STATE_RENDER(WINED3D_RS_DEPTHBIAS), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), state_colorwrite1 }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), state_colorwrite2 }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), state_colorwrite3 }, EXT_DRAW_BUFFERS2 },
{ STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_BLENDFACTOR), { STATE_RENDER(WINED3D_RS_BLENDFACTOR), state_blendfactor }, EXT_BLEND_COLOR },
{ STATE_RENDER(WINED3D_RS_BLENDFACTOR), { STATE_RENDER(WINED3D_RS_BLENDFACTOR), state_blendfactor_w }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEPTHBIAS), { STATE_RENDER(WINED3D_RS_DEPTHBIAS), state_depthbias }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_ZVISIBLE), { STATE_RENDER(WINED3D_RS_ZVISIBLE), state_zvisible }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEPTHCLIP), { STATE_RENDER(WINED3D_RS_DEPTHCLIP), state_depthclip }, ARB_DEPTH_CLAMP },
{ STATE_RENDER(WINED3D_RS_DEPTHCLIP), { STATE_RENDER(WINED3D_RS_DEPTHCLIP), state_depthclip_w }, WINED3D_GL_EXT_NONE },
/* Samplers */
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler }, WINED3D_GL_EXT_NONE },
@ -5293,30 +5217,6 @@ static const struct StateEntryTemplate vp_ffp_states[] =
{ STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(8), { STATE_CLIPPLANE(8), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(9), { STATE_CLIPPLANE(9), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(10), { STATE_CLIPPLANE(10), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(11), { STATE_CLIPPLANE(11), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(12), { STATE_CLIPPLANE(12), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(13), { STATE_CLIPPLANE(13), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(14), { STATE_CLIPPLANE(14), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(15), { STATE_CLIPPLANE(15), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(16), { STATE_CLIPPLANE(16), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(17), { STATE_CLIPPLANE(17), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(18), { STATE_CLIPPLANE(18), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(19), { STATE_CLIPPLANE(19), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(20), { STATE_CLIPPLANE(20), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(21), { STATE_CLIPPLANE(21), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(22), { STATE_CLIPPLANE(22), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(23), { STATE_CLIPPLANE(23), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(24), { STATE_CLIPPLANE(24), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(25), { STATE_CLIPPLANE(25), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(26), { STATE_CLIPPLANE(26), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(27), { STATE_CLIPPLANE(27), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(28), { STATE_CLIPPLANE(28), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(29), { STATE_CLIPPLANE(29), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane }, WINED3D_GL_EXT_NONE },
{ STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane }, WINED3D_GL_EXT_NONE },
/* Lights */
{ STATE_LIGHT_TYPE, { STATE_LIGHT_TYPE, state_nop }, WINED3D_GL_EXT_NONE },
{ STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light }, WINED3D_GL_EXT_NONE },
@ -6081,7 +5981,7 @@ static void validate_state_table(struct StateEntry *state_table)
if (i == STATE_RENDER(rs_holes[current].last)) ++current;
}
for (i = 0; i < sizeof(simple_states) / sizeof(*simple_states); ++i)
for (i = 0; i < ARRAY_SIZE(simple_states); ++i)
{
if (!state_table[simple_states[i]].representative)
ERR("State %s (%#x) should have a representative.\n",

View file

@ -43,10 +43,6 @@ static const DWORD pixel_states_render[] =
WINED3D_RS_COLORWRITEENABLE1,
WINED3D_RS_COLORWRITEENABLE2,
WINED3D_RS_COLORWRITEENABLE3,
WINED3D_RS_COLORWRITEENABLE4,
WINED3D_RS_COLORWRITEENABLE5,
WINED3D_RS_COLORWRITEENABLE6,
WINED3D_RS_COLORWRITEENABLE7,
WINED3D_RS_DEPTHBIAS,
WINED3D_RS_DESTBLEND,
WINED3D_RS_DESTBLENDALPHA,
@ -92,7 +88,6 @@ static const DWORD pixel_states_render[] =
WINED3D_RS_ZENABLE,
WINED3D_RS_ZFUNC,
WINED3D_RS_ZWRITEENABLE,
WINED3D_RS_DEPTHCLIP,
};
static const DWORD pixel_states_texture[] =
@ -221,7 +216,7 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states,
stateblock_set_bits(states->renderState, WINEHIGHEST_RENDER_STATE + 1);
for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = 0x3ffff;
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3ffe;
states->clipplane = 0xffffffff;
states->clipplane = (1u << MAX_CLIP_DISTANCES) - 1;
states->pixelShaderConstantsB = 0xffff;
states->pixelShaderConstantsI = 0xffff;
states->vertexShaderConstantsB = 0xffff;
@ -240,16 +235,16 @@ static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states
states->pixelShader = 1;
for (i = 0; i < sizeof(pixel_states_render) / sizeof(*pixel_states_render); ++i)
for (i = 0; i < ARRAY_SIZE(pixel_states_render); ++i)
{
DWORD rs = pixel_states_render[i];
states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
}
for (i = 0; i < sizeof(pixel_states_texture) / sizeof(*pixel_states_texture); ++i)
for (i = 0; i < ARRAY_SIZE(pixel_states_texture); ++i)
texture_mask |= 1u << pixel_states_texture[i];
for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = texture_mask;
for (i = 0; i < sizeof(pixel_states_sampler) / sizeof(*pixel_states_sampler); ++i)
for (i = 0; i < ARRAY_SIZE(pixel_states_sampler); ++i)
sampler_mask |= 1u << pixel_states_sampler[i];
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
states->pixelShaderConstantsB = 0xffff;
@ -267,16 +262,16 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state
states->vertexDecl = 1;
states->vertexShader = 1;
for (i = 0; i < sizeof(vertex_states_render) / sizeof(*vertex_states_render); ++i)
for (i = 0; i < ARRAY_SIZE(vertex_states_render); ++i)
{
DWORD rs = vertex_states_render[i];
states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
}
for (i = 0; i < sizeof(vertex_states_texture) / sizeof(*vertex_states_texture); ++i)
for (i = 0; i < ARRAY_SIZE(vertex_states_texture); ++i)
texture_mask |= 1u << vertex_states_texture[i];
for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = texture_mask;
for (i = 0; i < sizeof(vertex_states_sampler) / sizeof(*vertex_states_sampler); ++i)
for (i = 0; i < ARRAY_SIZE(vertex_states_sampler); ++i)
sampler_mask |= 1u << vertex_states_sampler[i];
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
states->vertexShaderConstantsB = 0xffff;
@ -1214,6 +1209,7 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
tmpfloat.f = gl_info->limits.pointsize_max;
state->render_states[WINED3D_RS_POINTSIZE_MAX] = tmpfloat.d;
state->render_states[WINED3D_RS_INDEXEDVERTEXBLENDENABLE] = FALSE;
state->render_states[WINED3D_RS_COLORWRITEENABLE] = 0x0000000f;
tmpfloat.f = 0.0f;
state->render_states[WINED3D_RS_TWEENFACTOR] = tmpfloat.d;
state->render_states[WINED3D_RS_BLENDOP] = WINED3D_BLEND_OP_ADD;
@ -1239,10 +1235,12 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
state->render_states[WINED3D_RS_BACK_STENCILZFAIL] = WINED3D_STENCIL_OP_KEEP;
state->render_states[WINED3D_RS_BACK_STENCILPASS] = WINED3D_STENCIL_OP_KEEP;
state->render_states[WINED3D_RS_BACK_STENCILFUNC] = WINED3D_CMP_ALWAYS;
state->render_states[WINED3D_RS_COLORWRITEENABLE1] = 0x0000000f;
state->render_states[WINED3D_RS_COLORWRITEENABLE2] = 0x0000000f;
state->render_states[WINED3D_RS_COLORWRITEENABLE3] = 0x0000000f;
state->render_states[WINED3D_RS_BLENDFACTOR] = 0xffffffff;
state->render_states[WINED3D_RS_SRGBWRITEENABLE] = 0;
state->render_states[WINED3D_RS_DEPTHBIAS] = 0;
state->render_states[WINED3D_RS_DEPTHCLIP] = TRUE;
state->render_states[WINED3D_RS_WRAP8] = 0;
state->render_states[WINED3D_RS_WRAP9] = 0;
state->render_states[WINED3D_RS_WRAP10] = 0;
@ -1255,8 +1253,6 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
state->render_states[WINED3D_RS_SRCBLENDALPHA] = WINED3D_BLEND_ONE;
state->render_states[WINED3D_RS_DESTBLENDALPHA] = WINED3D_BLEND_ZERO;
state->render_states[WINED3D_RS_BLENDOPALPHA] = WINED3D_BLEND_OP_ADD;
for (i = 0; i < MAX_RENDER_TARGETS; ++i)
state->render_states[WINED3D_RS_COLORWRITE(i)] = 0x0000000f;
/* Texture Stage States - Put directly into state block, we will call function below */
for (i = 0; i < MAX_TEXTURES; ++i)

View file

@ -365,7 +365,6 @@ static void surface_blt_fbo(const struct wined3d_device *device,
RECT src_rect, dst_rect;
GLenum gl_filter;
GLenum buffer;
int i;
TRACE("device %p, filter %s,\n", device, debug_d3dtexturefiltertype(filter));
TRACE("src_surface %p, src_location %s, src_rect %s,\n",
@ -463,8 +462,10 @@ static void surface_blt_fbo(const struct wined3d_device *device,
context_invalidate_state(context, STATE_FRAMEBUFFER);
gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
for (i = 0; i < MAX_RENDER_TARGETS; ++i)
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITE(i)));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2));
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3));
gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST);
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE));
@ -543,7 +544,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
void *mem;
/* Only support read back of converted P8 surfaces. */
if (texture->flags & WINED3D_TEXTURE_CONVERTED && format->id != WINED3DFMT_P8_UINT)
if (texture->flags & WINED3D_TEXTURE_CONVERTED && format->id != WINED3DFMT_P8_UINT && !format->download)
{
ERR("Trying to read back converted surface %p with format %s.\n", surface, debug_d3dformat(format->id));
return;
@ -553,6 +554,12 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
if (surface->texture_target == GL_TEXTURE_2D_ARRAY)
{
if (format->download)
{
FIXME("Reading back converted array texture %p is not supported.\n", texture);
return;
}
/* NP2 emulation is not allowed on array textures. */
if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
ERR("Array texture %p uses NP2 emulation.\n", texture);
@ -570,6 +577,12 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
{
if (format->download)
{
FIXME("Reading back converted texture %p with NP2 emulation is not supported.\n", texture);
return;
}
wined3d_texture_get_pitch(texture, surface->texture_level, &dst_row_pitch, &dst_slice_pitch);
wined3d_format_calculate_pitch(format, texture->resource.device->surface_alignment,
wined3d_texture_get_level_pow2_width(texture, surface->texture_level),
@ -587,6 +600,30 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
ERR("Unexpected compressed format for NP2 emulated texture.\n");
}
if (format->download)
{
struct wined3d_format f;
if (data.buffer_object)
ERR("Converted texture %p uses PBO unexpectedly.\n", texture);
WARN_(d3d_perf)("Downloading converted surface %p with format %s.\n", surface, debug_d3dformat(format->id));
f = *format;
f.byte_count = format->conv_byte_count;
wined3d_texture_get_pitch(texture, surface->texture_level, &dst_row_pitch, &dst_slice_pitch);
wined3d_format_calculate_pitch(&f, texture->resource.device->surface_alignment,
wined3d_texture_get_level_width(texture, surface->texture_level),
wined3d_texture_get_level_height(texture, surface->texture_level),
&src_row_pitch, &src_slice_pitch);
if (!(temporary_mem = HeapAlloc(GetProcessHeap(), 0, src_slice_pitch)))
{
ERR("Failed to allocate memory.\n");
return;
}
}
if (temporary_mem)
{
mem = temporary_mem;
@ -620,7 +657,13 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
checkGLcall("glGetTexImage");
}
if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
if (format->download)
{
format->download(mem, data.addr, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
wined3d_texture_get_level_width(texture, surface->texture_level),
wined3d_texture_get_level_height(texture, surface->texture_level), 1);
}
else if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
{
const BYTE *src_data;
unsigned int h, y;
@ -1212,126 +1255,6 @@ static void convert_yuy2_r5g6b5(const BYTE *src, BYTE *dst,
}
}
static void convert_dxt1_a8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
}
static void convert_dxt1_x8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
static void convert_dxt1_a4r4g4b4(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4A4_UNORM, w, h);
}
static void convert_dxt1_x4r4g4b4(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4X4_UNORM, w, h);
}
static void convert_dxt1_a1r5g5b5(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5A1_UNORM, w, h);
}
static void convert_dxt1_x1r5g5b5(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5X1_UNORM, w, h);
}
static void convert_dxt3_a8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
}
static void convert_dxt3_x8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
static void convert_dxt3_a4r4g4b4(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4A4_UNORM, w, h);
}
static void convert_dxt3_x4r4g4b4(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4X4_UNORM, w, h);
}
static void convert_dxt5_a8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt5_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
}
static void convert_dxt5_x8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt5_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
static void convert_a8r8g8b8_dxt1(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
}
static void convert_x8r8g8b8_dxt1(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
static void convert_a1r5g5b5_dxt1(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5A1_UNORM, w, h);
}
static void convert_x1r5g5b5_dxt1(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5X1_UNORM, w, h);
}
static void convert_a8r8g8b8_dxt3(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt3_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
}
static void convert_x8r8g8b8_dxt3(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt3_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
static void convert_a8r8g8b8_dxt5(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt5_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
}
static void convert_x8r8g8b8_dxt5(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
wined3d_dxt5_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
struct d3dfmt_converter_desc
{
enum wined3d_format_id from, to;
@ -1348,50 +1271,17 @@ static const struct d3dfmt_converter_desc converters[] =
{WINED3DFMT_YUY2, WINED3DFMT_B5G6R5_UNORM, convert_yuy2_r5g6b5},
};
static const struct d3dfmt_converter_desc dxtn_converters[] =
{
/* decode DXT */
{WINED3DFMT_DXT1, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt1_a8r8g8b8},
{WINED3DFMT_DXT1, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt1_x8r8g8b8},
{WINED3DFMT_DXT1, WINED3DFMT_B4G4R4A4_UNORM, convert_dxt1_a4r4g4b4},
{WINED3DFMT_DXT1, WINED3DFMT_B4G4R4X4_UNORM, convert_dxt1_x4r4g4b4},
{WINED3DFMT_DXT1, WINED3DFMT_B5G5R5A1_UNORM, convert_dxt1_a1r5g5b5},
{WINED3DFMT_DXT1, WINED3DFMT_B5G5R5X1_UNORM, convert_dxt1_x1r5g5b5},
{WINED3DFMT_DXT3, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt3_a8r8g8b8},
{WINED3DFMT_DXT3, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt3_x8r8g8b8},
{WINED3DFMT_DXT3, WINED3DFMT_B4G4R4A4_UNORM, convert_dxt3_a4r4g4b4},
{WINED3DFMT_DXT3, WINED3DFMT_B4G4R4X4_UNORM, convert_dxt3_x4r4g4b4},
{WINED3DFMT_DXT5, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt5_a8r8g8b8},
{WINED3DFMT_DXT5, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt5_x8r8g8b8},
/* encode DXT */
{WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_DXT1, convert_a8r8g8b8_dxt1},
{WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_DXT1, convert_x8r8g8b8_dxt1},
{WINED3DFMT_B5G5R5A1_UNORM, WINED3DFMT_DXT1, convert_a1r5g5b5_dxt1},
{WINED3DFMT_B5G5R5X1_UNORM, WINED3DFMT_DXT1, convert_x1r5g5b5_dxt1},
{WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_DXT3, convert_a8r8g8b8_dxt3},
{WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_DXT3, convert_x8r8g8b8_dxt3},
{WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_DXT5, convert_a8r8g8b8_dxt5},
{WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_DXT5, convert_x8r8g8b8_dxt5}
};
static inline const struct d3dfmt_converter_desc *find_converter(enum wined3d_format_id from,
enum wined3d_format_id to)
{
unsigned int i;
for (i = 0; i < (sizeof(converters) / sizeof(*converters)); ++i)
for (i = 0; i < ARRAY_SIZE(converters); ++i)
{
if (converters[i].from == from && converters[i].to == to)
return &converters[i];
}
for (i = 0; i < (sizeof(dxtn_converters) / sizeof(*dxtn_converters)); ++i)
{
if (dxtn_converters[i].from == from && dxtn_converters[i].to == to)
return wined3d_dxtn_supported() ? &dxtn_converters[i] : NULL;
}
return NULL;
}
@ -1411,8 +1301,8 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
DWORD map_binding;
if (!(conv = find_converter(src_format->id, dst_format->id)) && (!device->d3d_initialized
|| !is_identity_fixup(src_format->color_fixup) || src_format->convert
|| !is_identity_fixup(dst_format->color_fixup) || dst_format->convert
|| !is_identity_fixup(src_format->color_fixup) || src_format->conv_byte_count
|| !is_identity_fixup(dst_format->color_fixup) || dst_format->conv_byte_count
|| (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)))
{
FIXME("Cannot find a conversion function from format %s to %s.\n",
@ -2408,11 +2298,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
/* Don't use PBOs for converted surfaces. During PBO conversion we look at
* WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is
* getting called. */
#if !defined(STAGING_CSMT)
if ((format.convert || conversion) && texture->sub_resources[sub_resource_idx].buffer_object)
#else /* STAGING_CSMT */
if ((format.convert || conversion) && texture->sub_resources[sub_resource_idx].buffer)
#endif /* STAGING_CSMT */
if ((format.conv_byte_count || conversion) && texture->sub_resources[sub_resource_idx].buffer_object)
{
TRACE("Removing the pbo attached to surface %p.\n", surface);
@ -2421,7 +2307,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
}
wined3d_texture_get_memory(texture, sub_resource_idx, &data, sub_resource->locations);
if (format.convert)
if (format.conv_byte_count)
{
/* This code is entered for texture formats which need a fixup. */
format.byte_count = format.conv_byte_count;
@ -2435,7 +2321,7 @@ static BOOL surface_load_texture(struct wined3d_surface *surface,
context_release(context);
return FALSE;
}
format.convert(src_mem, dst_mem, src_row_pitch, src_slice_pitch,
format.upload(src_mem, dst_mem, src_row_pitch, src_slice_pitch,
dst_row_pitch, dst_slice_pitch, width, height, 1);
src_row_pitch = dst_row_pitch;
context_unmap_bo_address(context, &data, GL_PIXEL_UNPACK_BUFFER);
@ -2563,7 +2449,7 @@ static void fbo_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de
clear_rects, draw_rect, flags, colour, depth, stencil);
}
static void fbo_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
static DWORD fbo_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter)
@ -2571,34 +2457,43 @@ static void fbo_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_
struct wined3d_resource *src_resource = &src_surface->container->resource;
struct wined3d_resource *dst_resource = &dst_surface->container->resource;
struct wined3d_device *device = dst_resource->device;
enum wined3d_blit_op blit_op = op;
struct wined3d_blitter *next;
if (!fbo_blitter_supported(&device->adapter->gl_info, op,
if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_resource->format->id == src_resource->format->id)
{
if (dst_resource->format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
blit_op = WINED3D_BLIT_OP_DEPTH_BLIT;
else
blit_op = WINED3D_BLIT_OP_COLOR_BLIT;
}
if (!fbo_blitter_supported(&device->adapter->gl_info, blit_op,
src_resource->usage, src_resource->pool, src_resource->format, src_location,
src_resource->usage, dst_resource->pool, dst_resource->format, dst_location))
{
if ((next = blitter->next))
next->ops->blitter_blit(next, op, context, src_surface, src_location,
return next->ops->blitter_blit(next, op, context, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect, colour_key, filter);
return;
}
if (op == WINED3D_BLIT_OP_COLOR_BLIT)
if (blit_op == WINED3D_BLIT_OP_COLOR_BLIT)
{
TRACE("Colour blit.\n");
surface_blt_fbo(device, context, filter, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect);
return;
return dst_location;
}
if (op == WINED3D_BLIT_OP_DEPTH_BLIT)
if (blit_op == WINED3D_BLIT_OP_DEPTH_BLIT)
{
TRACE("Depth/stencil blit.\n");
surface_depth_blt_fbo(device, src_surface, src_location, src_rect, dst_surface, dst_location, dst_rect);
return;
return dst_location;
}
ERR("This blitter does not implement blit op %#x.\n", op);
ERR("This blitter does not implement blit op %#x.\n", blit_op);
return dst_location;
}
static const struct wined3d_blitter_ops fbo_blitter_ops =
@ -2625,6 +2520,138 @@ void wined3d_fbo_blitter_create(struct wined3d_blitter **next, const struct wine
*next = blitter;
}
/* Context activation is done by the caller. */
static void raw_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_context *context)
{
struct wined3d_blitter *next;
if ((next = blitter->next))
next->ops->blitter_destroy(next, context);
HeapFree(GetProcessHeap(), 0, blitter);
}
/* Context activation is done by the caller. */
static void raw_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device,
unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil)
{
struct wined3d_blitter *next;
if (!(next = blitter->next))
{
ERR("No blitter to handle clear.\n");
return;
}
TRACE("Forwarding to blitter %p.\n", next);
next->ops->blitter_clear(next, device, rt_count, fb, rect_count,
clear_rects, draw_rect, flags, colour, depth, stencil);
}
/* Context activation is done by the caller. */
static DWORD raw_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int src_sub_resource_idx, dst_sub_resource_idx;
struct wined3d_texture *src_texture, *dst_texture;
struct wined3d_blitter *next;
GLuint src_name, dst_name;
DWORD location;
src_texture = src_surface->container;
dst_texture = dst_surface->container;
/* If we would need to copy from a renderbuffer or drawable, we'd probably
* be better of using the FBO blitter directly, since we'd need to use it
* to copy the resource contents to the texture anyway. */
if (op != WINED3D_BLIT_OP_RAW_BLIT
|| (src_texture->resource.format->id == dst_texture->resource.format->id
&& (!(src_location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
|| !(dst_location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB)))))
{
if (!(next = blitter->next))
{
ERR("No blitter to handle blit op %#x.\n", op);
return dst_location;
}
TRACE("Forwarding to blitter %p.\n", next);
return next->ops->blitter_blit(next, op, context, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect, colour_key, filter);
}
TRACE("Blit using ARB_copy_image.\n");
src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
location = src_location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB);
if (!location)
location = src_texture->flags & WINED3D_TEXTURE_IS_SRGB
? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB;
if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, location))
ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(location));
src_name = wined3d_texture_get_texture_name(src_texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB);
location = dst_location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB);
if (!location)
location = dst_texture->flags & WINED3D_TEXTURE_IS_SRGB
? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB;
if (surface_is_full_rect(dst_surface, dst_rect))
{
if (!wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, location))
ERR("Failed to prepare the destination sub-resource into %s.\n", wined3d_debug_location(location));
}
else
{
if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, location))
ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(location));
}
dst_name = wined3d_texture_get_texture_name(dst_texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB);
GL_EXTCALL(glCopyImageSubData(src_name, src_texture->target, src_surface->texture_level,
src_rect->left, src_rect->top, src_surface->texture_layer,
dst_name, dst_texture->target, dst_surface->texture_level,
dst_rect->left, dst_rect->top, dst_surface->texture_layer,
src_rect->right - src_rect->left, src_rect->bottom - src_rect->top, 1));
checkGLcall("copy image data");
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, location);
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~location);
if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, dst_location))
ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(dst_location));
return dst_location | location;
}
static const struct wined3d_blitter_ops raw_blitter_ops =
{
raw_blitter_destroy,
raw_blitter_clear,
raw_blitter_blit,
};
void wined3d_raw_blitter_create(struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info)
{
struct wined3d_blitter *blitter;
if (!gl_info->supported[ARB_COPY_IMAGE])
return;
if (!(blitter = HeapAlloc(GetProcessHeap(), 0, sizeof(*blitter))))
return;
TRACE("Created blitter %p.\n", blitter);
blitter->ops = &raw_blitter_ops;
blitter->next = *next;
*next = blitter;
}
/* Context activation is done by the caller. */
static void ffp_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_context *context)
{
@ -2651,6 +2678,14 @@ static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info,
return FALSE;
}
if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_format->id == src_format->id)
{
if (dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
blit_op = WINED3D_BLIT_OP_DEPTH_BLIT;
else
blit_op = WINED3D_BLIT_OP_COLOR_BLIT;
}
switch (blit_op)
{
case WINED3D_BLIT_OP_COLOR_BLIT_CKEY:
@ -2694,7 +2729,7 @@ static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info,
return TRUE;
default:
TRACE("Unsupported blit_op=%d\n", blit_op);
TRACE("Unsupported blit operation %#x.\n", blit_op);
return FALSE;
}
}
@ -2703,13 +2738,15 @@ static BOOL ffp_blitter_use_cpu_clear(struct wined3d_rendertarget_view *view)
{
struct wined3d_resource *resource;
struct wined3d_texture *texture;
DWORD locations;
resource = view->resource;
if (resource->type == WINED3D_RTYPE_BUFFER)
return resource->pool == WINED3D_POOL_SYSTEM_MEM;
texture = texture_from_resource(resource);
if (texture->sub_resources[view->sub_resource_idx].locations & resource->map_binding)
locations = texture->sub_resources[view->sub_resource_idx].locations;
if (locations & (resource->map_binding | WINED3D_LOCATION_DISCARDED))
return resource->pool == WINED3D_POOL_SYSTEM_MEM || (texture->flags & WINED3D_TEXTURE_PIN_SYSMEM);
return resource->pool == WINED3D_POOL_SYSTEM_MEM && !(texture->flags & WINED3D_TEXTURE_CONVERTED);
@ -2764,7 +2801,7 @@ static void ffp_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de
clear_rects, draw_rect, next_flags, colour, depth, stencil);
}
static void ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
@ -2788,9 +2825,8 @@ static void ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_
dst_resource->usage, dst_resource->pool, dst_resource->format, dst_location))
{
if ((next = blitter->next))
next->ops->blitter_blit(next, op, context, src_surface, src_location,
return next->ops->blitter_blit(next, op, context, src_surface, src_location,
src_rect, dst_surface, dst_location, dst_rect, color_key, filter);
return;
}
TRACE("Blt from surface %p to rendertarget %p\n", src_surface, dst_surface);
@ -2885,6 +2921,8 @@ static void ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_
/* Restore the color key parameters */
wined3d_texture_set_color_key(src_texture, WINED3D_CKEY_SRC_BLT,
(old_color_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL);
return dst_location;
}
static const struct wined3d_blitter_ops ffp_blitter_ops =
@ -3077,7 +3115,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
same_sub_resource = FALSE;
dst_format = dst_texture->resource.format;
dst_fmt_flags = dst_texture->resource.format_flags;
if (dst_texture->resource.format->id != src_texture->resource.format->id)
if (!(flags & WINED3D_BLT_RAW) && dst_texture->resource.format->id != src_texture->resource.format->id)
{
if (!(converted_texture = surface_convert_format(src_texture, src_sub_resource_idx, dst_format)))
{
@ -3112,6 +3150,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
dst_map.data = context_map_bo_address(context, &dst_data,
dst_texture->sub_resources[dst_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, 0);
}
flags &= ~WINED3D_BLT_RAW;
bpp = dst_format->byte_count;
src_height = src_box->bottom - src_box->top;
@ -3155,8 +3194,7 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int
&& (src_width != dst_width || src_height != dst_height))
{
/* Can happen when d3d9 apps do a StretchRect() call which isn't handled in GL. */
static int once;
if (!once++) FIXME("Filter %s not supported in software blit.\n", debug_d3dtexturefiltertype(filter));
FIXME("Filter %s not supported in software blit.\n", debug_d3dtexturefiltertype(filter));
}
xinc = (src_width << 16) / dst_width;
@ -3656,7 +3694,7 @@ static void cpu_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de
}
}
static void cpu_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
static DWORD cpu_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op,
struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location,
const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
@ -3675,6 +3713,7 @@ static void cpu_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_
{
case WINED3D_BLIT_OP_COLOR_BLIT:
case WINED3D_BLIT_OP_DEPTH_BLIT:
case WINED3D_BLIT_OP_RAW_BLIT:
break;
case WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST:
flags |= WINED3D_BLT_ALPHA_TEST;
@ -3692,6 +3731,9 @@ static void cpu_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_
src_texture, src_sub_resource_idx, &src_box, flags, &fx, filter)))
ERR("Failed to blit.\n");
wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, dst_location);
return dst_location | (dst_texture->sub_resources[dst_sub_resource_idx].locations
& dst_texture->resource.map_binding);
}
static const struct wined3d_blitter_ops cpu_blitter_ops =
@ -3730,15 +3772,16 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
struct wined3d_device *device = dst_texture->resource.device;
struct wined3d_swapchain *src_swapchain, *dst_swapchain;
const struct wined3d_color_key *colour_key = NULL;
DWORD dst_location, valid_locations;
DWORD src_ds_flags, dst_ds_flags;
struct wined3d_context *context;
enum wined3d_blit_op blit_op;
BOOL scale, convert;
DWORD dst_location;
static const DWORD simple_blit = WINED3D_BLT_SRC_CKEY
| WINED3D_BLT_SRC_CKEY_OVERRIDE
| WINED3D_BLT_ALPHA_TEST;
| WINED3D_BLT_ALPHA_TEST
| WINED3D_BLT_RAW;
TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
@ -3776,16 +3819,6 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
goto cpu;
}
/* We want to avoid invalidating the sysmem location for converted
* surfaces, since otherwise we'd have to convert the data back when
* locking them. */
if (dst_texture->flags & WINED3D_TEXTURE_CONVERTED || dst_texture->resource.format->convert
|| wined3d_format_get_color_key_conversion(dst_texture, TRUE))
{
WARN_(d3d_perf)("Converted surface, using CPU blit.\n");
goto cpu;
}
if (flags & ~simple_blit)
{
WARN_(d3d_perf)("Using fallback for complex blit (%#x).\n", flags);
@ -3825,13 +3858,14 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
dst_location = dst_texture->resource.draw_binding;
context = context_acquire(device, dst_texture, dst_sub_resource_idx);
device->blitter->ops->blitter_blit(device->blitter, WINED3D_BLIT_OP_DEPTH_BLIT, context,
valid_locations = device->blitter->ops->blitter_blit(device->blitter,
WINED3D_BLIT_OP_DEPTH_BLIT, context,
src_surface, src_texture->resource.draw_binding, src_rect,
dst_surface, dst_location, dst_rect, NULL, filter);
context_release(context);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, dst_location);
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_location);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, valid_locations);
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~valid_locations);
return WINED3D_OK;
}
@ -3869,14 +3903,16 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
{
blit_op = WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST;
}
else if ((src_sub_resource->locations & WINED3D_LOCATION_SYSMEM)
&& !(dst_sub_resource->locations & WINED3D_LOCATION_SYSMEM))
else if ((src_sub_resource->locations & surface_simple_locations)
&& !(dst_sub_resource->locations & surface_simple_locations))
{
/* Upload */
if (scale)
TRACE("Not doing upload because of scaling.\n");
else if (convert)
TRACE("Not doing upload because of format conversion.\n");
else if (dst_texture->resource.format->conv_byte_count)
TRACE("Not doing upload because the destination format needs conversion.\n");
else
{
POINT dst_point = {dst_rect->left, dst_rect->top};
@ -3916,6 +3952,10 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
return WINED3D_OK;
}
else if ((flags & WINED3D_BLT_RAW) || (!scale && !convert))
{
blit_op = WINED3D_BLIT_OP_RAW_BLIT;
}
if (dst_texture->resource.pool == WINED3D_POOL_SYSTEM_MEM)
dst_location = dst_texture->resource.map_binding;
@ -3923,13 +3963,13 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
dst_location = dst_texture->resource.draw_binding;
context = context_acquire(device, dst_texture, dst_sub_resource_idx);
device->blitter->ops->blitter_blit(device->blitter, blit_op, context,
valid_locations = device->blitter->ops->blitter_blit(device->blitter, blit_op, context,
src_surface, src_texture->resource.draw_binding, src_rect,
dst_surface, dst_location, dst_rect, colour_key, filter);
context_release(context);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, dst_location);
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_location);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, valid_locations);
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~valid_locations);
return WINED3D_OK;

View file

@ -146,18 +146,14 @@ void CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWN
HRESULT CDECL wined3d_swapchain_present(struct wined3d_swapchain *swapchain,
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD flags)
{
static DWORD notified_flags = 0;
RECT s, d;
TRACE("swapchain %p, src_rect %s, dst_rect %s, dst_window_override %p, flags %#x.\n",
swapchain, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect),
dst_window_override, flags);
if (flags & ~notified_flags)
{
FIXME("Ignoring flags %#x.\n", flags & ~notified_flags);
notified_flags |= flags;
}
if (flags)
FIXME("Ignoring flags %#x.\n", flags);
if (!swapchain->back_buffers)
{
@ -480,11 +476,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
swapchain_blit(swapchain, context, src_rect, dst_rect);
}
#if !defined(STAGING_CSMT)
if (swapchain->num_contexts > 1)
#else /* STAGING_CSMT */
if (swapchain->num_contexts > 1 && !wined3d_settings.cs_multithreaded)
#endif /* STAGING_CSMT */
gl_info->gl_ops.gl.p_glFinish();
/* call wglSwapBuffers through the gl table to avoid confusing the Steam overlay */
@ -1435,6 +1427,7 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha
device->filter_messages = TRUE;
MoveWindow(swapchain->device_window, 0, 0, width, height, TRUE);
ShowWindow(swapchain->device_window, SW_SHOW);
device->filter_messages = filter_messages;
}

View file

@ -33,7 +33,7 @@ static BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const
return texture->resource.pool == WINED3D_POOL_DEFAULT
&& texture->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU
&& gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
&& !texture->resource.format->convert
&& !texture->resource.format->conv_byte_count
&& !(texture->flags & (WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_COND_NP2_EMULATED));
}
@ -99,11 +99,6 @@ static DWORD wined3d_resource_access_from_location(DWORD location)
}
}
static BOOL is_power_of_two(UINT x)
{
return (x != 0) && !(x & (x - 1));
}
static void wined3d_texture_evict_sysmem(struct wined3d_texture *texture)
{
struct wined3d_texture_sub_resource *sub_resource;
@ -292,11 +287,7 @@ void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int su
if (locations & WINED3D_LOCATION_BUFFER)
{
data->addr = NULL;
#if !defined(STAGING_CSMT)
data->buffer_object = sub_resource->buffer_object;
#else /* STAGING_CSMT */
data->buffer_object = sub_resource->buffer->name;
#endif /* STAGING_CSMT */
return;
}
if (locations & WINED3D_LOCATION_USER_MEMORY)
@ -391,13 +382,21 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
texture->flags |= WINED3D_TEXTURE_GET_DC;
if (flags & WINED3D_TEXTURE_CREATE_DISCARD)
texture->flags |= WINED3D_TEXTURE_DISCARD;
if (flags & WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS)
{
if (~format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
& (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))
WARN("Format doesn't support mipmaps generation, "
"ignoring WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS flag.\n");
else
texture->flags |= WINED3D_TEXTURE_GENERATE_MIPMAPS;
}
return WINED3D_OK;
}
/* Context activation is done by the caller. */
static void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture,
#if !defined(STAGING_CSMT)
unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info)
{
GLuint *buffer_object = &texture->sub_resources[sub_resource_idx].buffer_object;
@ -410,19 +409,6 @@ static void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture
wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_BUFFER);
*buffer_object = 0;
#else /* STAGING_CSMT */
unsigned int sub_resource_idx, struct wined3d_context *context)
{
struct wined3d_gl_bo *buffer = texture->sub_resources[sub_resource_idx].buffer;
GLuint name = buffer->name;
wined3d_device_release_bo(texture->resource.device, buffer, context);
texture->sub_resources[sub_resource_idx].buffer = NULL;
wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_BUFFER);
TRACE("Deleted buffer object %u for texture %p, sub-resource %u.\n",
name, texture, sub_resource_idx);
#endif /* STAGING_CSMT */
}
static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
@ -442,11 +428,7 @@ static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
&& !wined3d_texture_load_location(texture, i, context, map_binding))
ERR("Failed to load location %s.\n", wined3d_debug_location(map_binding));
if (texture->resource.map_binding == WINED3D_LOCATION_BUFFER)
#if !defined(STAGING_CSMT)
wined3d_texture_remove_buffer_object(texture, i, context->gl_info);
#else /* STAGING_CSMT */
wined3d_texture_remove_buffer_object(texture, i, context);
#endif /* STAGING_CSMT */
}
if (context)
@ -603,46 +585,28 @@ static void wined3d_texture_cleanup(struct wined3d_texture *texture)
unsigned int sub_count = texture->level_count * texture->layer_count;
struct wined3d_device *device = texture->resource.device;
struct wined3d_context *context = NULL;
#if !defined(STAGING_CSMT)
const struct wined3d_gl_info *gl_info;
GLuint buffer_object;
#else /* STAGING_CSMT */
struct wined3d_gl_bo *buffer;
#endif /* STAGING_CSMT */
unsigned int i;
TRACE("texture %p.\n", texture);
for (i = 0; i < sub_count; ++i)
{
#if !defined(STAGING_CSMT)
if (!(buffer_object = texture->sub_resources[i].buffer_object))
continue;
TRACE("Deleting buffer object %u.\n", buffer_object);
#else /* STAGING_CSMT */
if (!(buffer = texture->sub_resources[i].buffer))
continue;
TRACE("Deleting buffer object %u.\n", buffer->name);
#endif /* STAGING_CSMT */
/* We may not be able to get a context in wined3d_texture_cleanup() in
* general, but if a buffer object was previously created we can. */
if (!context)
#if !defined(STAGING_CSMT)
{
context = context_acquire(device, NULL, 0);
gl_info = context->gl_info;
}
GL_EXTCALL(glDeleteBuffers(1, &buffer_object));
#else /* STAGING_CSMT */
context = context_acquire(device, NULL, 0);
wined3d_device_release_bo(device, buffer, context);
texture->sub_resources[i].buffer = NULL;
#endif /* STAGING_CSMT */
}
if (context)
context_release(context);
@ -894,8 +858,8 @@ void wined3d_texture_apply_sampler_desc(struct wined3d_texture *texture,
state = sampler_desc->max_anisotropy;
if (state != gl_tex->sampler_desc.max_anisotropy)
{
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, state);
if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC])
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAX_ANISOTROPY, state);
else
WARN("Anisotropic filtering not supported.\n");
gl_tex->sampler_desc.max_anisotropy = state;
@ -1344,12 +1308,6 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
return WINED3DERR_INVALIDCALL;
}
if (texture->resource.type == WINED3D_RTYPE_TEXTURE_1D)
{
FIXME("Not yet supported for 1D textures.\n");
return WINED3DERR_INVALIDCALL;
}
if (texture->resource.map_count)
{
WARN("Texture is mapped.\n");
@ -1400,7 +1358,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
sub_resource->size = texture->slice_pitch;
sub_resource->locations = WINED3D_LOCATION_DISCARDED;
if ((!is_power_of_two(width) || !is_power_of_two(height)) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]
if (((width & (width - 1)) || (height & (height - 1))) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]
&& !gl_info->supported[ARB_TEXTURE_RECTANGLE] && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
{
texture->flags |= WINED3D_TEXTURE_COND_NP2_EMULATED;
@ -1449,16 +1407,11 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
/* Context activation is done by the caller. */
static void wined3d_texture_prepare_buffer_object(struct wined3d_texture *texture,
#if !defined(STAGING_CSMT)
unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info)
#else /* STAGING_CSMT */
unsigned int sub_resource_idx, struct wined3d_context *context)
#endif /* STAGING_CSMT */
{
struct wined3d_texture_sub_resource *sub_resource;
sub_resource = &texture->sub_resources[sub_resource_idx];
#if !defined(STAGING_CSMT)
if (sub_resource->buffer_object)
return;
@ -1470,16 +1423,6 @@ static void wined3d_texture_prepare_buffer_object(struct wined3d_texture *textur
TRACE("Created buffer object %u for texture %p, sub-resource %u.\n",
sub_resource->buffer_object, texture, sub_resource_idx);
#else /* STAGING_CSMT */
if (sub_resource->buffer)
return;
sub_resource->buffer = wined3d_device_get_bo(texture->resource.device,
sub_resource->size, GL_STREAM_DRAW, GL_PIXEL_UNPACK_BUFFER, context);
TRACE("Created buffer object %u for texture %p, sub-resource %u.\n",
sub_resource->buffer->name, texture, sub_resource_idx);
#endif /* STAGING_CSMT */
}
static void wined3d_texture_force_reload(struct wined3d_texture *texture)
@ -1605,11 +1548,7 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned
return TRUE;
case WINED3D_LOCATION_BUFFER:
#if !defined(STAGING_CSMT)
wined3d_texture_prepare_buffer_object(texture, sub_resource_idx, context->gl_info);
#else /* STAGING_CSMT */
wined3d_texture_prepare_buffer_object(texture, sub_resource_idx, context);
#endif /* STAGING_CSMT */
return TRUE;
case WINED3D_LOCATION_TEXTURE_RGB:
@ -1639,12 +1578,6 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned
}
}
void CDECL wined3d_texture_generate_mipmaps(struct wined3d_texture *texture)
{
/* TODO: Implement filters using GL_SGI_generate_mipmaps. */
FIXME("texture %p stub!\n", texture);
}
static struct wined3d_texture_sub_resource *wined3d_texture_get_sub_resource(struct wined3d_texture *texture,
unsigned int sub_resource_idx)
{
@ -1673,7 +1606,7 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
}
if (dirty_region)
WARN("Ignoring dirty_region %s.\n", debug_box(dirty_region));
FIXME("Ignoring dirty_region %s.\n", debug_box(dirty_region));
wined3d_cs_emit_add_dirty_texture_region(texture->resource.device->cs, texture, layer);
@ -1688,380 +1621,6 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
context, box, data, row_pitch, slice_pitch);
}
/* This call just uploads data, the caller is responsible for binding the
* correct texture. */
/* Context activation is done by the caller. */
static void texture1d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data,
unsigned int row_pitch, unsigned int slice_pitch)
{
struct wined3d_surface *surface = texture->sub_resources[sub_resource_idx].u.surface;
const struct wined3d_format *format = texture->resource.format;
unsigned int level = sub_resource_idx % texture->level_count;
const struct wined3d_gl_info *gl_info = context->gl_info;
const void *mem = data->addr;
void *converted_mem = NULL;
unsigned int width, x, update_w;
TRACE("texture %p, sub_resource_idx %u, context %p, box %p, data {%#x:%p}, row_pitch %#x, slice_pitch %#x.\n",
texture, sub_resource_idx, context, box, data->buffer_object, data->addr, row_pitch, slice_pitch);
width = wined3d_texture_get_level_width(texture, level);
if (!box)
{
x = 0;
update_w = width;
}
else
{
x = box->left;
update_w = box->right - box->left;
}
if (format->convert)
{
unsigned int dst_row_pitch;
if (data->buffer_object)
ERR("Loading a converted texture from a PBO.\n");
if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
ERR("Converting a block-based format.\n");
dst_row_pitch = update_w * format->conv_byte_count;
converted_mem = HeapAlloc(GetProcessHeap(), 0, dst_row_pitch);
format->convert(data->addr, converted_mem, row_pitch, slice_pitch, dst_row_pitch, dst_row_pitch, update_w, 1, 1);
mem = converted_mem;
}
if (data->buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, data->buffer_object));
checkGLcall("glBindBuffer");
}
if (surface->texture_target == GL_TEXTURE_1D_ARRAY)
{
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, row_pitch / format->byte_count);
gl_info->gl_ops.gl.p_glTexSubImage2D(surface->texture_target, level, x, surface->texture_layer, update_w, 1, format->glFormat, format->glType, mem);
checkGLcall("glTexSubImage2D");
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
else
{
gl_info->gl_ops.gl.p_glTexSubImage1D(surface->texture_target, level, x, update_w, format->glFormat, format->glType, mem);
checkGLcall("glTexSubImage1D");
}
if (data->buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
checkGLcall("glBindBuffer");
}
HeapFree(GetProcessHeap(), 0, converted_mem);
}
/* Context activation is done by the caller. */
static void texture1d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_context *context, const struct wined3d_bo_address *data)
{
struct wined3d_surface *surface = texture->sub_resources[sub_resource_idx].u.surface;
const struct wined3d_format *format = texture->resource.format;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_texture_sub_resource *sub_resource;
BYTE *temporary_mem = NULL;
void *mem;
sub_resource = &texture->sub_resources[sub_resource_idx];
if (format->convert)
{
FIXME("Attempting to download a converted 1d texture, format %s.\n",
debug_d3dformat(format->id));
return;
}
if (surface->texture_target == GL_TEXTURE_1D_ARRAY)
{
WARN_(d3d_perf)("Downloading all miplevel layers to get the surface data for a single sub-resource.\n");
if (!(temporary_mem = wined3d_calloc(texture->layer_count, sub_resource->size)))
{
ERR("Out of memory.\n");
return;
}
mem = temporary_mem;
}
else if (data->buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
checkGLcall("glBindBuffer");
mem = data->addr;
}
else
mem = data->addr;
gl_info->gl_ops.gl.p_glGetTexImage(surface->texture_target, sub_resource_idx,
format->glFormat, format->glType, mem);
checkGLcall("glGetTexImage");
if (temporary_mem)
{
void *src_data = temporary_mem + surface->texture_layer * sub_resource->size;
if (data->buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
checkGLcall("glBindBuffer");
GL_EXTCALL(glBufferSubData(GL_PIXEL_PACK_BUFFER, 0, sub_resource->size, src_data));
checkGLcall("glBufferSubData");
}
else
{
memcpy(data->addr, src_data, sub_resource->size);
}
}
if (data->buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
checkGLcall("glBindBuffer");
}
HeapFree(GetProcessHeap(), 0, temporary_mem);
}
/* Context activation is done by the caller. */
static void texture1d_srgb_transfer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, BOOL dest_is_srgb)
{
struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
unsigned int row_pitch, slice_pitch;
struct wined3d_bo_address data;
WARN_(d3d_perf)("Performing slow rgb/srgb 1d texture transfer.\n");
data.buffer_object = 0;
if (!(data.addr = HeapAlloc(GetProcessHeap(), 0, sub_resource->size)))
return;
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
wined3d_texture_bind_and_dirtify(texture, context, !dest_is_srgb);
texture1d_download_data(texture, sub_resource_idx, context, &data);
wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb);
texture1d_upload_data(texture, sub_resource_idx, context, NULL,
wined3d_const_bo_address(&data), row_pitch, slice_pitch);
HeapFree(GetProcessHeap(), 0, data.addr);
}
/* Context activation is done by the caller. */
static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location)
{
struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
DWORD required_access = wined3d_resource_access_from_location(location);
unsigned int row_pitch, slice_pitch;
TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
texture, sub_resource_idx, context, wined3d_debug_location(location));
TRACE("Current resource location %s.\n", wined3d_debug_location(sub_resource->locations));
if ((sub_resource->locations & location) == location)
{
TRACE("Location(s) already up to date.\n");
return TRUE;
}
if ((texture->resource.access_flags & required_access) != required_access)
{
ERR("Operation requires %#x access, but 1d texture only has %#x.\n",
required_access, texture->resource.access_flags);
return FALSE;
}
if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location))
return FALSE;
if (sub_resource->locations & WINED3D_LOCATION_DISCARDED)
{
TRACE("1d texture previously discarded, nothing to do.\n");
wined3d_texture_validate_location(texture, sub_resource_idx, location);
wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_DISCARDED);
goto done;
}
switch (location)
{
case WINED3D_LOCATION_TEXTURE_RGB:
case WINED3D_LOCATION_TEXTURE_SRGB:
if (sub_resource->locations & WINED3D_LOCATION_SYSMEM)
{
struct wined3d_const_bo_address data = {0, texture->resource.heap_memory};
data.addr += sub_resource->offset;
wined3d_texture_bind_and_dirtify(texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB);
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
texture1d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
}
else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
{
#if !defined(STAGING_CSMT)
struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL};
#else /* STAGING_CSMT */
struct wined3d_const_bo_address data = {sub_resource->buffer->name, NULL};
#endif /* STAGING_CSMT */
wined3d_texture_bind_and_dirtify(texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB);
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
texture1d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
}
else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
{
texture1d_srgb_transfer(texture, sub_resource_idx, context, TRUE);
}
else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_SRGB)
{
texture1d_srgb_transfer(texture, sub_resource_idx, context, FALSE);
}
else
{
FIXME("Implement 1d texture loading from %s.\n", wined3d_debug_location(sub_resource->locations));
return FALSE;
}
break;
case WINED3D_LOCATION_SYSMEM:
if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
{
struct wined3d_bo_address data = {0, texture->resource.heap_memory};
data.addr += sub_resource->offset;
if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
wined3d_texture_bind_and_dirtify(texture, context, FALSE);
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
texture1d_download_data(texture, sub_resource_idx, context, &data);
++texture->download_count;
}
else
{
FIXME("Implement WINED3D_LOCATION_SYSMEM loading from %s.\n",
wined3d_debug_location(sub_resource->locations));
return FALSE;
}
break;
case WINED3D_LOCATION_BUFFER:
if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
{
#if !defined(STAGING_CSMT)
struct wined3d_bo_address data = {sub_resource->buffer_object, NULL};
#else /* STAGING_CSMT */
struct wined3d_bo_address data = {sub_resource->buffer->name, NULL};
#endif /* STAGING_CSMT */
if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
wined3d_texture_bind_and_dirtify(texture, context, FALSE);
else
wined3d_texture_bind_and_dirtify(texture, context, TRUE);
texture1d_download_data(texture, sub_resource_idx, context, &data);
}
else
{
FIXME("Implement WINED3D_LOCATION_BUFFER loading from %s.\n",
wined3d_debug_location(sub_resource->locations));
return FALSE;
}
break;
default:
FIXME("Implement %s loading from %s.\n", wined3d_debug_location(location),
wined3d_debug_location(sub_resource->locations));
return FALSE;
}
done:
wined3d_texture_validate_location(texture, sub_resource_idx, location);
return TRUE;
}
static void texture1d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
{
const struct wined3d_format *format = texture->resource.format;
unsigned int sub_count = texture->level_count * texture->layer_count;
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int width;
GLenum internal;
wined3d_texture_bind_and_dirtify(texture, context, srgb);
if (srgb)
internal = format->glGammaInternal;
else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET
&& wined3d_resource_is_offscreen(&texture->resource))
internal = format->rtInternal;
else
internal = format->glInternal;
if (wined3d_texture_use_immutable_storage(texture, gl_info))
{
width = wined3d_texture_get_level_width(texture, 0);
if (texture->target == GL_TEXTURE_1D_ARRAY)
{
GL_EXTCALL(glTexStorage2D(texture->target, texture->level_count, internal, width, texture->layer_count));
checkGLcall("glTexStorage2D");
}
else
{
GL_EXTCALL(glTexStorage1D(texture->target, texture->level_count, internal, width));
checkGLcall("glTexStorage1D");
}
}
else
{
unsigned int i;
for (i = 0; i < sub_count; ++i)
{
struct wined3d_surface *surface = texture->sub_resources[i].u.surface;
width = wined3d_texture_get_level_width(texture, surface->texture_level);
if (texture->target == GL_TEXTURE_1D_ARRAY)
{
gl_info->gl_ops.gl.p_glTexImage2D(surface->texture_target, surface->texture_level,
internal, width, texture->layer_count, 0, format->glFormat, format->glType, NULL);
checkGLcall("glTexImage2D");
}
else
{
gl_info->gl_ops.gl.p_glTexImage1D(surface->texture_target, surface->texture_level,
internal, width, 0, format->glFormat, format->glType, NULL);
checkGLcall("glTexImage1D");
}
}
}
}
static void texture1d_cleanup_sub_resources(struct wined3d_texture *texture)
{
}
static const struct wined3d_texture_ops texture1d_ops =
{
texture1d_upload_data,
texture1d_load_location,
texture1d_prepare_texture,
texture1d_cleanup_sub_resources,
};
static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_context *context, const struct wined3d_box *box,
const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
@ -2107,7 +1666,7 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
TRACE("texture %p, context %p, format %s.\n", texture, context, debug_d3dformat(format->id));
if (format->convert)
if (format->conv_byte_count)
{
texture->flags |= WINED3D_TEXTURE_CONVERTED;
}
@ -2257,13 +1816,8 @@ static void wined3d_texture_unload(struct wined3d_resource *resource)
wined3d_texture_invalidate_location(texture, i, ~WINED3D_LOCATION_DISCARDED);
}
#if !defined(STAGING_CSMT)
if (sub_resource->buffer_object)
wined3d_texture_remove_buffer_object(texture, i, context->gl_info);
#else /* STAGING_CSMT */
if (sub_resource->buffer)
wined3d_texture_remove_buffer_object(texture, i, context);
#endif /* STAGING_CSMT */
if (resource->type == WINED3D_RTYPE_TEXTURE_2D)
{
@ -2426,36 +1980,6 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
return WINED3D_OK;
}
static HRESULT texture_resource_sub_resource_map_info(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_info *info, DWORD flags)
{
const struct wined3d_format *format = resource->format;
struct wined3d_texture_sub_resource *sub_resource;
unsigned int fmt_flags = resource->format_flags;
struct wined3d_texture *texture;
unsigned int texture_level;
texture = texture_from_resource(resource);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
return E_INVALIDARG;
texture_level = sub_resource_idx % texture->level_count;
if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH)
{
info->row_pitch = wined3d_texture_get_level_width(texture, texture_level) * format->byte_count;
info->slice_pitch = wined3d_texture_get_level_height(texture, texture_level) * info->row_pitch;
}
else
{
wined3d_texture_get_pitch(texture, texture_level, &info->row_pitch, &info->slice_pitch);
}
info->size = info->slice_pitch * wined3d_texture_get_level_depth(texture, texture_level);
return WINED3D_OK;
}
static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
struct wined3d_texture_sub_resource *sub_resource;
@ -2507,141 +2031,9 @@ static const struct wined3d_resource_ops texture_resource_ops =
texture_resource_preload,
wined3d_texture_unload,
texture_resource_sub_resource_map,
texture_resource_sub_resource_map_info,
texture_resource_sub_resource_unmap,
};
static HRESULT texture1d_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
UINT layer_count, UINT level_count, struct wined3d_device *device, void *parent,
const struct wined3d_parent_ops *parent_ops)
{
struct wined3d_device_parent *device_parent = device->device_parent;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_surface *surfaces;
unsigned int i, j;
HRESULT hr;
if (layer_count > 1 && !gl_info->supported[EXT_TEXTURE_ARRAY])
{
WARN("OpenGL implementation does not support array textures.\n");
return WINED3DERR_INVALIDCALL;
}
/* TODO: It should only be possible to create textures for formats
* that are reported as supported. */
if (WINED3DFMT_UNKNOWN >= desc->format)
{
WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
return WINED3DERR_INVALIDCALL;
}
if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP)
{
WARN("1d textures can not be used for cube mapping, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (desc->usage & WINED3DUSAGE_DYNAMIC && (desc->pool == WINED3D_POOL_MANAGED
|| desc->pool == WINED3D_POOL_SCRATCH))
{
WARN("Attempted to create a DYNAMIC texture in pool %s.\n", debug_d3dpool(desc->pool));
return WINED3DERR_INVALIDCALL;
}
if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] && !is_power_of_two(desc->width))
{
if (desc->pool == WINED3D_POOL_SCRATCH)
{
WARN("Creating a scratch NPOT 1d texture despite lack of HW support.\n");
}
else
{
WARN("Attempted to create a NPOT 1d texture (%u, %u, %u) without GL support.\n",
desc->width, desc->height, desc->depth);
return WINED3DERR_INVALIDCALL;
}
}
if (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP)
{
if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
{
WARN("No mipmap generation support, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (level_count != 1)
{
WARN("WINED3DUSAGE_AUTOGENMIPMAP is set, and level count != 1, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
}
if (FAILED(hr = wined3d_texture_init(texture, &texture1d_ops, layer_count, level_count, desc,
0, device, parent, parent_ops, &texture_resource_ops)))
{
WARN("Failed to initialize texture, returning %#x.\n", hr);
return hr;
}
texture->pow2_matrix[0] = 1.0f;
texture->pow2_matrix[5] = 1.0f;
texture->pow2_matrix[10] = 1.0f;
texture->pow2_matrix[15] = 1.0f;
texture->target = (layer_count > 1) ? GL_TEXTURE_1D_ARRAY : GL_TEXTURE_1D;
if (wined3d_texture_use_pbo(texture, gl_info))
{
wined3d_resource_free_sysmem(&texture->resource);
texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
}
if (level_count > ~(SIZE_T)0 / layer_count
|| !(surfaces = wined3d_calloc(level_count * layer_count, sizeof(*surfaces))))
{
wined3d_texture_cleanup_sync(texture);
return E_OUTOFMEMORY;
}
/* Generate all the surfaces. */
for (i = 0; i < texture->level_count; ++i)
{
for (j = 0; j < texture->layer_count; ++j)
{
struct wined3d_texture_sub_resource *sub_resource;
unsigned int idx = j * texture->level_count + i;
struct wined3d_surface *surface;
surface = &surfaces[idx];
surface->container = texture;
surface->texture_target = texture->target;
surface->texture_level = i;
surface->texture_layer = j;
list_init(&surface->renderbuffers);
list_init(&surface->overlays);
sub_resource = &texture->sub_resources[idx];
sub_resource->locations = WINED3D_LOCATION_DISCARDED;
sub_resource->u.surface = surface;
if (FAILED(hr = device_parent->ops->surface_created(device_parent,
texture, idx, &sub_resource->parent, &sub_resource->parent_ops)))
{
WARN("Failed to create texture1d parent, hr %#x.\n", hr);
sub_resource->parent = NULL;
wined3d_texture_cleanup_sync(texture);
return hr;
}
TRACE("parent %p, parent_ops %p.\n", parent, parent_ops);
TRACE("Created 1d texture surface level %u, layer %u @ %p.\n", i, j, surface);
}
}
return WINED3D_OK;
}
static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
unsigned int layer_count, unsigned int level_count, DWORD flags, struct wined3d_device *device,
void *parent, const struct wined3d_parent_ops *parent_ops)
@ -2912,7 +2304,7 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int
update_d = box->back - box->front;
}
if (format->convert)
if (format->conv_byte_count)
{
if (data->buffer_object)
ERR("Loading a converted texture from a PBO.\n");
@ -2923,7 +2315,7 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int
dst_slice_pitch = dst_row_pitch * update_h;
converted_mem = wined3d_calloc(update_d, dst_slice_pitch);
format->convert(data->addr, converted_mem, row_pitch, slice_pitch,
format->upload(data->addr, converted_mem, row_pitch, slice_pitch,
dst_row_pitch, dst_slice_pitch, update_w, update_h, update_d);
mem = converted_mem;
}
@ -2960,7 +2352,7 @@ static void texture3d_download_data(struct wined3d_texture *texture, unsigned in
const struct wined3d_format *format = texture->resource.format;
const struct wined3d_gl_info *gl_info = context->gl_info;
if (format->convert)
if (format->conv_byte_count)
{
FIXME("Attempting to download a converted volume, format %s.\n",
debug_d3dformat(format->id));
@ -3039,11 +2431,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
}
else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
{
#if !defined(STAGING_CSMT)
struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL};
#else /* STAGING_CSMT */
struct wined3d_const_bo_address data = {sub_resource->buffer->name, NULL};
#endif /* STAGING_CSMT */
wined3d_texture_bind_and_dirtify(texture, context,
location == WINED3D_LOCATION_TEXTURE_SRGB);
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
@ -3089,11 +2477,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
case WINED3D_LOCATION_BUFFER:
if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
{
#if !defined(STAGING_CSMT)
struct wined3d_bo_address data = {sub_resource->buffer_object, NULL};
#else /* STAGING_CSMT */
struct wined3d_bo_address data = {sub_resource->buffer->name, NULL};
#endif /* STAGING_CSMT */
if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
wined3d_texture_bind_and_dirtify(texture, context, FALSE);
@ -3164,7 +2548,7 @@ static const struct wined3d_texture_ops texture3d_ops =
};
static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
UINT layer_count, UINT level_count, struct wined3d_device *device, void *parent,
UINT layer_count, UINT level_count, DWORD flags, struct wined3d_device *device, void *parent,
const struct wined3d_parent_ops *parent_ops)
{
struct wined3d_device_parent *device_parent = device->device_parent;
@ -3217,7 +2601,18 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
{
if (!is_power_of_two(desc->width) || !is_power_of_two(desc->height) || !is_power_of_two(desc->depth))
UINT pow2_w, pow2_h, pow2_d;
pow2_w = 1;
while (pow2_w < desc->width)
pow2_w <<= 1;
pow2_h = 1;
while (pow2_h < desc->height)
pow2_h <<= 1;
pow2_d = 1;
while (pow2_d < desc->depth)
pow2_d <<= 1;
if (pow2_w != desc->width || pow2_h != desc->height || pow2_d != desc->depth)
{
if (desc->pool == WINED3D_POOL_SCRATCH)
{
@ -3233,7 +2628,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
}
if (FAILED(hr = wined3d_texture_init(texture, &texture3d_ops, 1, level_count, desc,
0, device, parent, parent_ops, &texture_resource_ops)))
flags, device, parent, parent_ops, &texture_resource_ops)))
{
WARN("Failed to initialize texture, returning %#x.\n", hr);
return hr;
@ -3311,19 +2706,8 @@ HRESULT CDECL wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigned
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
|| src_texture->sub_resources[src_sub_resource_idx].map_count)
{
#if !defined(STAGING_CSMT)
WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
return WINEDDERR_SURFACEBUSY;
#else /* STAGING_CSMT */
struct wined3d_device *device = dst_texture->resource.device;
device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
|| (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
{
WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
return WINEDDERR_SURFACEBUSY;
}
#endif /* STAGING_CSMT */
}
if ((src_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
@ -3579,16 +2963,12 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
switch (desc->resource_type)
{
case WINED3D_RTYPE_TEXTURE_1D:
hr = texture1d_init(object, desc, layer_count, level_count, device, parent, parent_ops);
break;
case WINED3D_RTYPE_TEXTURE_2D:
hr = texture_init(object, desc, layer_count, level_count, flags, device, parent, parent_ops);
break;
case WINED3D_RTYPE_TEXTURE_3D:
hr = volumetexture_init(object, desc, layer_count, level_count, device, parent, parent_ops);
hr = volumetexture_init(object, desc, layer_count, level_count, flags, device, parent, parent_ops);
break;
default:

View file

@ -227,9 +227,9 @@ static const struct wined3d_typed_format_info typed_formats[] =
{WINED3DFMT_R10G10B10A2_UNORM, WINED3DFMT_R10G10B10A2_TYPELESS, "uuuu"},
{WINED3DFMT_R8G8B8A8_UINT, WINED3DFMT_R8G8B8A8_TYPELESS, "UUUU"},
{WINED3DFMT_R8G8B8A8_SINT, WINED3DFMT_R8G8B8A8_TYPELESS, "IIII"},
{WINED3DFMT_R8G8B8A8_SNORM, WINED3DFMT_R8G8B8A8_TYPELESS, "iiii"},
{WINED3DFMT_R8G8B8A8_UNORM_SRGB, WINED3DFMT_R8G8B8A8_TYPELESS, "uuuu"},
{WINED3DFMT_R8G8B8A8_UNORM, WINED3DFMT_R8G8B8A8_TYPELESS, "uuuu"},
{WINED3DFMT_R8G8B8A8_SNORM, WINED3DFMT_R8G8B8A8_TYPELESS, "iiii"},
{WINED3DFMT_R16G16_UNORM, WINED3DFMT_R16G16_TYPELESS, "uu"},
{WINED3DFMT_R16G16_SNORM, WINED3DFMT_R16G16_TYPELESS, "ii"},
{WINED3DFMT_R16G16_UINT, WINED3DFMT_R16G16_TYPELESS, "UU"},
@ -263,6 +263,7 @@ static const struct wined3d_typed_format_info typed_formats[] =
{WINED3DFMT_BC3_UNORM_SRGB, WINED3DFMT_BC3_TYPELESS, ""},
{WINED3DFMT_BC3_UNORM, WINED3DFMT_BC3_TYPELESS, ""},
{WINED3DFMT_BC4_UNORM, WINED3DFMT_BC4_TYPELESS, ""},
{WINED3DFMT_BC4_SNORM, WINED3DFMT_BC4_TYPELESS, ""},
{WINED3DFMT_BC5_UNORM, WINED3DFMT_BC5_TYPELESS, ""},
{WINED3DFMT_BC5_SNORM, WINED3DFMT_BC5_TYPELESS, ""},
{WINED3DFMT_BC6H_UF16, WINED3DFMT_BC6H_TYPELESS, ""},
@ -281,16 +282,17 @@ struct wined3d_typeless_format_depth_stencil_info
enum wined3d_format_id depth_stencil_id;
enum wined3d_format_id depth_view_id;
enum wined3d_format_id stencil_view_id;
BOOL separate_depth_view_format;
};
static const struct wined3d_typeless_format_depth_stencil_info typeless_depth_stencil_formats[] =
{
{WINED3DFMT_R32G8X24_TYPELESS, WINED3DFMT_D32_FLOAT_S8X24_UINT,
WINED3DFMT_R32_FLOAT_X8X24_TYPELESS, WINED3DFMT_X32_TYPELESS_G8X24_UINT},
WINED3DFMT_R32_FLOAT_X8X24_TYPELESS, WINED3DFMT_X32_TYPELESS_G8X24_UINT, TRUE},
{WINED3DFMT_R24G8_TYPELESS, WINED3DFMT_D24_UNORM_S8_UINT,
WINED3DFMT_R24_UNORM_X8_TYPELESS, WINED3DFMT_X24_TYPELESS_G8_UINT},
{WINED3DFMT_R32_TYPELESS, WINED3DFMT_D32_FLOAT},
{WINED3DFMT_R16_TYPELESS, WINED3DFMT_D16_UNORM},
WINED3DFMT_R24_UNORM_X8_TYPELESS, WINED3DFMT_X24_TYPELESS_G8_UINT, TRUE},
{WINED3DFMT_R32_TYPELESS, WINED3DFMT_D32_FLOAT, WINED3DFMT_R32_FLOAT},
{WINED3DFMT_R16_TYPELESS, WINED3DFMT_D16_UNORM, WINED3DFMT_R16_UNORM},
};
struct wined3d_format_ddi_info
@ -329,6 +331,10 @@ static const struct wined3d_format_base_flags format_base_flags[] =
{WINED3DFMT_D32_FLOAT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_S8_UINT_D24_FLOAT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_D32_FLOAT_S8X24_UINT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_INST, WINED3DFMT_FLAG_EXTENSION},
{WINED3DFMT_NULL, WINED3DFMT_FLAG_EXTENSION},
{WINED3DFMT_NVDB, WINED3DFMT_FLAG_EXTENSION},
{WINED3DFMT_RESZ, WINED3DFMT_FLAG_EXTENSION},
};
struct wined3d_format_block_info
@ -351,6 +357,7 @@ static const struct wined3d_format_block_info format_block_info[] =
{WINED3DFMT_BC2_UNORM, 4, 4, 16, TRUE},
{WINED3DFMT_BC3_UNORM, 4, 4, 16, TRUE},
{WINED3DFMT_BC4_UNORM, 4, 4, 8, TRUE},
{WINED3DFMT_BC4_SNORM, 4, 4, 8, TRUE},
{WINED3DFMT_BC5_UNORM, 4, 4, 16, TRUE},
{WINED3DFMT_BC5_SNORM, 4, 4, 16, TRUE},
{WINED3DFMT_BC6H_UF16, 4, 4, 16, TRUE},
@ -397,6 +404,7 @@ static const struct wined3d_format_vertex_info format_vertex_info[] =
{WINED3DFMT_R8G8B8A8_SNORM, WINED3D_FFP_EMIT_INVALID, 4, GL_BYTE, GL_TRUE },
{WINED3DFMT_R8G8B8A8_SINT, WINED3D_FFP_EMIT_INVALID, 4, GL_BYTE, GL_FALSE},
{WINED3DFMT_R16G16B16A16_UINT, WINED3D_FFP_EMIT_INVALID, 4, GL_UNSIGNED_SHORT, GL_FALSE},
{WINED3DFMT_R8_UNORM, WINED3D_FFP_EMIT_INVALID, 1, GL_UNSIGNED_BYTE, GL_TRUE},
{WINED3DFMT_R8_UINT, WINED3D_FFP_EMIT_INVALID, 1, GL_UNSIGNED_BYTE, GL_FALSE},
{WINED3DFMT_R8_SINT, WINED3D_FFP_EMIT_INVALID, 1, GL_BYTE, GL_FALSE},
{WINED3DFMT_R16_UINT, WINED3D_FFP_EMIT_INVALID, 1, GL_UNSIGNED_SHORT, GL_FALSE},
@ -421,8 +429,12 @@ struct wined3d_format_texture_info
unsigned int conv_byte_count;
unsigned int flags;
enum wined3d_gl_extension extension;
void (*convert)(const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch,
UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth);
void (*upload)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
unsigned int dst_row_pitch, unsigned int dst_slice_pitch,
unsigned int width, unsigned int height, unsigned int depth);
void (*download)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
unsigned int dst_row_pitch, unsigned int dst_slice_pitch,
unsigned int width, unsigned int height, unsigned int depth);
};
static void convert_l4a4_unorm(const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch,
@ -826,8 +838,10 @@ static void convert_s8_uint_d24_float(const BYTE *src, BYTE *dst, UINT src_row_p
}
}
static void convert_x8_d24_unorm(const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch,
UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
static void x8_d24_unorm_upload(const BYTE *src, BYTE *dst,
unsigned int src_row_pitch, unsigned int src_slice_pitch,
unsigned int dst_row_pitch, unsigned int dst_slice_pitch,
unsigned int width, unsigned int height, unsigned int depth)
{
unsigned int x, y, z;
@ -840,7 +854,29 @@ static void convert_x8_d24_unorm(const BYTE *src, BYTE *dst, UINT src_row_pitch,
for (x = 0; x < width; ++x)
{
dest[x] = source[x] << 8 | source[x] >> 16;
dest[x] = source[x] << 8 | ((source[x] >> 16) & 0xff);
}
}
}
}
static void x8_d24_unorm_download(const BYTE *src, BYTE *dst,
unsigned int src_row_pitch, unsigned int src_slice_pitch,
unsigned int dst_row_pitch, unsigned int dst_slice_pitch,
unsigned int width, unsigned int height, unsigned int depth)
{
unsigned int x, y, z;
for (z = 0; z < depth; ++z)
{
for (y = 0; y < height; ++y)
{
const DWORD *source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
DWORD *dest = (DWORD *)(dst + z * dst_slice_pitch + y * dst_row_pitch);
for (x = 0; x < width; ++x)
{
dest[x] = source[x] >> 8;
}
}
}
@ -1075,7 +1111,7 @@ static const struct wined3d_format_texture_info format_texture_info[] =
/* format id gl_internal gl_srgb_internal gl_rt_internal
gl_format gl_type conv_byte_count
flags
extension convert */
extension upload download */
/* FourCC formats */
/* GL_APPLE_ycbcr_422 claims that its '2YUV' format, which is supported via the UNSIGNED_SHORT_8_8_REV_APPLE type
* is equivalent to 'UYVY' format on Windows, and the 'YUVS' via UNSIGNED_SHORT_8_8_APPLE equates to 'YUY2'. The
@ -1168,6 +1204,11 @@ static const struct wined3d_format_texture_info format_texture_info[] =
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING
| WINED3DFMT_FLAG_COMPRESSED,
ARB_TEXTURE_COMPRESSION_RGTC, NULL},
{WINED3DFMT_BC4_SNORM, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, 0,
GL_RED, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING
| WINED3DFMT_FLAG_COMPRESSED,
ARB_TEXTURE_COMPRESSION_RGTC, NULL},
{WINED3DFMT_BC5_UNORM, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, 0,
GL_RG, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING
@ -1549,7 +1590,7 @@ static const struct wined3d_format_texture_info format_texture_info[] =
GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0,
WINED3DFMT_FLAG_DEPTH,
WINED3D_GL_EXT_NONE, NULL},
{WINED3DFMT_D16_LOCKABLE, GL_DEPTH_COMPONENT24_ARB, GL_DEPTH_COMPONENT24_ARB, 0,
{WINED3DFMT_D16_LOCKABLE, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0,
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_SHADOW,
ARB_DEPTH_TEXTURE, NULL},
@ -1561,7 +1602,7 @@ static const struct wined3d_format_texture_info format_texture_info[] =
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0,
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_SHADOW,
ARB_DEPTH_TEXTURE, NULL},
{WINED3DFMT_S1_UINT_D15_UNORM, GL_DEPTH_COMPONENT24_ARB, GL_DEPTH_COMPONENT24_ARB, 0,
{WINED3DFMT_S1_UINT_D15_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0,
WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_SHADOW,
ARB_DEPTH_TEXTURE, NULL},
@ -1591,12 +1632,12 @@ static const struct wined3d_format_texture_info format_texture_info[] =
{WINED3DFMT_X8D24_UNORM, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 4,
WINED3DFMT_FLAG_DEPTH,
WINED3D_GL_EXT_NONE, convert_x8_d24_unorm},
WINED3D_GL_EXT_NONE, x8_d24_unorm_upload, x8_d24_unorm_download},
{WINED3DFMT_X8D24_UNORM, GL_DEPTH_COMPONENT24_ARB, GL_DEPTH_COMPONENT24_ARB, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 4,
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING
| WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_SHADOW,
ARB_DEPTH_TEXTURE, convert_x8_d24_unorm},
ARB_DEPTH_TEXTURE, x8_d24_unorm_upload, x8_d24_unorm_download},
{WINED3DFMT_S4X4_UINT_D24_UNORM, GL_DEPTH_COMPONENT24_ARB, GL_DEPTH_COMPONENT24_ARB, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0,
WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_SHADOW,
@ -1613,7 +1654,7 @@ static const struct wined3d_format_texture_info format_texture_info[] =
GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0,
WINED3DFMT_FLAG_DEPTH,
WINED3D_GL_EXT_NONE, NULL},
{WINED3DFMT_D16_UNORM, GL_DEPTH_COMPONENT24_ARB, GL_DEPTH_COMPONENT24_ARB, 0,
{WINED3DFMT_D16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0,
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING
| WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_SHADOW,
@ -1638,10 +1679,6 @@ static const struct wined3d_format_texture_info format_texture_info[] =
GL_RGBA_INTEGER, GL_INT, 0,
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET,
EXT_TEXTURE_INTEGER, NULL},
{WINED3DFMT_R24_UNORM_X8_TYPELESS, GL_DEPTH_COMPONENT24_ARB, GL_DEPTH_COMPONENT24_ARB, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8, 0,
WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_DEPTH,
ARB_DEPTH_TEXTURE, NULL},
/* Vendor-specific formats */
{WINED3DFMT_ATI1N, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, 0,
GL_RED, GL_UNSIGNED_BYTE, 0,
@ -2936,8 +2973,9 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
query_internal_format(adapter, format, &format_texture_info[i], gl_info, srgb_write, FALSE);
/* Texture conversion stuff */
format->convert = format_texture_info[i].convert;
format->conv_byte_count = format_texture_info[i].conv_byte_count;
format->upload = format_texture_info[i].upload;
format->download = format_texture_info[i].download;
srgb_format = NULL;
for (j = 0; j < ARRAY_SIZE(format_srgb_info); ++j)
@ -3226,7 +3264,8 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
if (!gl_info->supported[APPLE_YCBCR_422])
if (!gl_info->supported[APPLE_YCBCR_422] && gl_info->supported[ARB_FRAGMENT_PROGRAM]
&& gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
{
idx = get_format_idx(WINED3DFMT_YUY2);
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
@ -3234,18 +3273,38 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
idx = get_format_idx(WINED3DFMT_UYVY);
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
}
else if (!gl_info->supported[APPLE_YCBCR_422] && (!gl_info->supported[ARB_FRAGMENT_PROGRAM]
|| !gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]))
{
idx = get_format_idx(WINED3DFMT_YUY2);
gl_info->formats[idx].glInternal = 0;
idx = get_format_idx(WINED3DFMT_YV12);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
gl_info->formats[idx].height_scale.numerator = 3;
gl_info->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
idx = get_format_idx(WINED3DFMT_UYVY);
gl_info->formats[idx].glInternal = 0;
}
idx = get_format_idx(WINED3DFMT_NV12);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
gl_info->formats[idx].height_scale.numerator = 3;
gl_info->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
if (gl_info->supported[ARB_FRAGMENT_PROGRAM] && gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
{
idx = get_format_idx(WINED3DFMT_YV12);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
gl_info->formats[idx].height_scale.numerator = 3;
gl_info->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
idx = get_format_idx(WINED3DFMT_NV12);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
gl_info->formats[idx].height_scale.numerator = 3;
gl_info->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
}
else
{
idx = get_format_idx(WINED3DFMT_YV12);
gl_info->formats[idx].glInternal = 0;
idx = get_format_idx(WINED3DFMT_NV12);
gl_info->formats[idx].glInternal = 0;
}
if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
{
@ -3412,6 +3471,8 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC4_UNORM);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC4_SNORM);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC5_UNORM);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC5_SNORM);
@ -3516,7 +3577,8 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
typeless_format->flags[j] &= ~(WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
}
if ((format_id = typeless_depth_stencil_formats[i].depth_view_id))
if ((format_id = typeless_depth_stencil_formats[i].depth_view_id)
&& typeless_depth_stencil_formats[i].separate_depth_view_format)
{
if (!(depth_view_format = get_format_internal(gl_info, format_id)))
return FALSE;
@ -3533,33 +3595,6 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
return TRUE;
}
/* Context activation is done by the caller. */
BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
{
struct wined3d_gl_info *gl_info = &adapter->gl_info;
if (!init_format_base_info(gl_info)) return FALSE;
if (!init_format_block_info(gl_info)) goto fail;
if (!ctx) /* WINED3D_NO3D */
return TRUE;
if (!init_format_texture_info(adapter, gl_info)) goto fail;
if (!init_format_vertex_info(gl_info)) goto fail;
apply_format_fixups(adapter, gl_info);
init_format_fbo_compat_info(ctx);
init_format_filter_info(gl_info, adapter->driver_info.vendor);
if (!init_typeless_formats(gl_info)) goto fail;
return TRUE;
fail:
HeapFree(GetProcessHeap(), 0, gl_info->formats);
gl_info->formats = NULL;
return FALSE;
}
BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx)
{
static const struct wined3d_color red = {1.0f, 0.0f, 0.0f, 1.0f};
@ -3607,7 +3642,7 @@ BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx
return TRUE;
}
float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLenum format)
static float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLenum format)
{
const struct wined3d_gl_info *gl_info = ctx->gl_info;
static const struct wined3d_color blue = {0.0f, 0.0f, 1.0f, 1.0f};
@ -3685,7 +3720,7 @@ float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLe
low = cur;
else
{
TRACE("Found scale factor 2^%u for format %x\n", cur, format);
TRACE("Found scale factor 2^%u for format %x.\n", cur, format);
break;
}
}
@ -3701,6 +3736,63 @@ float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLe
return (float)(1u << cur);
}
static void init_format_depth_bias_scale(struct wined3d_caps_gl_ctx *ctx,
const struct wined3d_d3d_info *d3d_info)
{
const struct wined3d_gl_info *gl_info = ctx->gl_info;
unsigned int i;
for (i = 0; i < gl_info->format_count; ++i)
{
struct wined3d_format *format = &gl_info->formats[i];
if (format->flags[WINED3D_GL_RES_TYPE_RB] & WINED3DFMT_FLAG_DEPTH)
{
TRACE("Testing depth bias scale for format %s.\n", debug_d3dformat(format->id));
format->depth_bias_scale = wined3d_adapter_find_polyoffset_scale(ctx, format->glInternal);
if (!(d3d_info->wined3d_creation_flags & WINED3D_NORMALIZED_DEPTH_BIAS))
{
/* The single-precision binary floating-point format has
* a significand precision of 24 bits.
*/
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
format->depth_bias_scale /= 1u << 24;
else
format->depth_bias_scale /= 1u << format->depth_size;
}
}
}
}
/* Context activation is done by the caller. */
BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
{
struct wined3d_gl_info *gl_info = &adapter->gl_info;
if (!init_format_base_info(gl_info)) return FALSE;
if (!init_format_block_info(gl_info)) goto fail;
if (!ctx) /* WINED3D_NO3D */
return TRUE;
if (!init_format_texture_info(adapter, gl_info)) goto fail;
if (!init_format_vertex_info(gl_info)) goto fail;
apply_format_fixups(adapter, gl_info);
init_format_fbo_compat_info(ctx);
init_format_filter_info(gl_info, adapter->driver_info.vendor);
if (!init_typeless_formats(gl_info)) goto fail;
init_format_depth_bias_scale(ctx, &adapter->d3d_info);
return TRUE;
fail:
HeapFree(GetProcessHeap(), 0, gl_info->formats);
gl_info->formats = NULL;
return FALSE;
}
const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info,
enum wined3d_format_id format_id, unsigned int resource_usage)
{
@ -3733,6 +3825,19 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl
return format;
}
BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
enum wined3d_format_id view_format_id)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(typeless_depth_stencil_formats); ++i)
{
if (typeless_depth_stencil_formats[i].typeless_id == resource_format_id)
return typeless_depth_stencil_formats[i].depth_view_id == view_format_id;
}
return FALSE;
}
void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch)
{
@ -3779,6 +3884,20 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
return slice_pitch * depth;
}
BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1, enum wined3d_format_id format2)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(format_srgb_info); ++i)
{
if (format1 == format_srgb_info[i].srgb_format_id)
return format2 == format_srgb_info[i].base_format_id;
if (format1 == format_srgb_info[i].base_format_id)
return format2 == format_srgb_info[i].srgb_format_id;
}
return FALSE;
}
/*****************************************************************************
* Trace formatting of useful values
*/
@ -4128,7 +4247,6 @@ const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type)
#define WINED3D_TO_STR(x) case x: return #x
WINED3D_TO_STR(WINED3D_RTYPE_NONE);
WINED3D_TO_STR(WINED3D_RTYPE_BUFFER);
WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_1D);
WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_2D);
WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_3D);
#undef WINED3D_TO_STR
@ -4255,6 +4373,7 @@ const char *debug_d3drenderstate(enum wined3d_render_state state)
D3DSTATE_TO_STR(WINED3D_RS_DEBUGMONITORTOKEN);
D3DSTATE_TO_STR(WINED3D_RS_POINTSIZE_MAX);
D3DSTATE_TO_STR(WINED3D_RS_INDEXEDVERTEXBLENDENABLE);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE);
D3DSTATE_TO_STR(WINED3D_RS_TWEENFACTOR);
D3DSTATE_TO_STR(WINED3D_RS_BLENDOP);
D3DSTATE_TO_STR(WINED3D_RS_POSITIONDEGREE);
@ -4274,14 +4393,9 @@ const char *debug_d3drenderstate(enum wined3d_render_state state)
D3DSTATE_TO_STR(WINED3D_RS_BACK_STENCILZFAIL);
D3DSTATE_TO_STR(WINED3D_RS_BACK_STENCILPASS);
D3DSTATE_TO_STR(WINED3D_RS_BACK_STENCILFUNC);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE1);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE2);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE3);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE4);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE5);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE6);
D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE7);
D3DSTATE_TO_STR(WINED3D_RS_BLENDFACTOR);
D3DSTATE_TO_STR(WINED3D_RS_SRGBWRITEENABLE);
D3DSTATE_TO_STR(WINED3D_RS_DEPTHBIAS);
@ -4297,7 +4411,6 @@ const char *debug_d3drenderstate(enum wined3d_render_state state)
D3DSTATE_TO_STR(WINED3D_RS_SRCBLENDALPHA);
D3DSTATE_TO_STR(WINED3D_RS_DESTBLENDALPHA);
D3DSTATE_TO_STR(WINED3D_RS_BLENDOPALPHA);
D3DSTATE_TO_STR(WINED3D_RS_DEPTHCLIP);
#undef D3DSTATE_TO_STR
default:
FIXME("Unrecognized %u render state!\n", state);
@ -5235,281 +5348,6 @@ void multiply_matrix(struct wined3d_matrix *dst, const struct wined3d_matrix *sr
*dst = tmp;
}
/* Taken and adapted from Mesa. */
BOOL invert_matrix_3d(struct wined3d_matrix *out, const struct wined3d_matrix *in)
{
float pos, neg, t, det;
struct wined3d_matrix temp;
/* Calculate the determinant of upper left 3x3 submatrix and
* determine if the matrix is singular. */
pos = neg = 0.0f;
t = in->_11 * in->_22 * in->_33;
if (t >= 0.0f)
pos += t;
else
neg += t;
t = in->_21 * in->_32 * in->_13;
if (t >= 0.0f)
pos += t;
else
neg += t;
t = in->_31 * in->_12 * in->_23;
if (t >= 0.0f)
pos += t;
else
neg += t;
t = -in->_31 * in->_22 * in->_13;
if (t >= 0.0f)
pos += t;
else
neg += t;
t = -in->_21 * in->_12 * in->_33;
if (t >= 0.0f)
pos += t;
else
neg += t;
t = -in->_11 * in->_32 * in->_23;
if (t >= 0.0f)
pos += t;
else
neg += t;
det = pos + neg;
if (fabsf(det) < 1e-25f)
return FALSE;
det = 1.0f / det;
temp._11 = (in->_22 * in->_33 - in->_32 * in->_23) * det;
temp._12 = -(in->_12 * in->_33 - in->_32 * in->_13) * det;
temp._13 = (in->_12 * in->_23 - in->_22 * in->_13) * det;
temp._21 = -(in->_21 * in->_33 - in->_31 * in->_23) * det;
temp._22 = (in->_11 * in->_33 - in->_31 * in->_13) * det;
temp._23 = -(in->_11 * in->_23 - in->_21 * in->_13) * det;
temp._31 = (in->_21 * in->_32 - in->_31 * in->_22) * det;
temp._32 = -(in->_11 * in->_32 - in->_31 * in->_12) * det;
temp._33 = (in->_11 * in->_22 - in->_21 * in->_12) * det;
*out = temp;
return TRUE;
}
static void swap_rows(float **a, float **b)
{
float *tmp = *a;
*a = *b;
*b = tmp;
}
BOOL invert_matrix(struct wined3d_matrix *out, struct wined3d_matrix *m)
{
float wtmp[4][8];
float m0, m1, m2, m3, s;
float *r0, *r1, *r2, *r3;
r0 = wtmp[0];
r1 = wtmp[1];
r2 = wtmp[2];
r3 = wtmp[3];
r0[0] = m->_11;
r0[1] = m->_12;
r0[2] = m->_13;
r0[3] = m->_14;
r0[4] = 1.0f;
r0[5] = r0[6] = r0[7] = 0.0f;
r1[0] = m->_21;
r1[1] = m->_22;
r1[2] = m->_23;
r1[3] = m->_24;
r1[5] = 1.0f;
r1[4] = r1[6] = r1[7] = 0.0f;
r2[0] = m->_31;
r2[1] = m->_32;
r2[2] = m->_33;
r2[3] = m->_34;
r2[6] = 1.0f;
r2[4] = r2[5] = r2[7] = 0.0f;
r3[0] = m->_41;
r3[1] = m->_42;
r3[2] = m->_43;
r3[3] = m->_44;
r3[7] = 1.0f;
r3[4] = r3[5] = r3[6] = 0.0f;
/* Choose pivot - or die. */
if (fabsf(r3[0]) > fabsf(r2[0]))
swap_rows(&r3, &r2);
if (fabsf(r2[0]) > fabsf(r1[0]))
swap_rows(&r2, &r1);
if (fabsf(r1[0]) > fabsf(r0[0]))
swap_rows(&r1, &r0);
if (r0[0] == 0.0f)
return FALSE;
/* Eliminate first variable. */
m1 = r1[0] / r0[0]; m2 = r2[0] / r0[0]; m3 = r3[0] / r0[0];
s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
s = r0[4];
if (s != 0.0f)
{
r1[4] -= m1 * s;
r2[4] -= m2 * s;
r3[4] -= m3 * s;
}
s = r0[5];
if (s != 0.0f)
{
r1[5] -= m1 * s;
r2[5] -= m2 * s;
r3[5] -= m3 * s;
}
s = r0[6];
if (s != 0.0f)
{
r1[6] -= m1 * s;
r2[6] -= m2 * s;
r3[6] -= m3 * s;
}
s = r0[7];
if (s != 0.0f)
{
r1[7] -= m1 * s;
r2[7] -= m2 * s;
r3[7] -= m3 * s;
}
/* Choose pivot - or die. */
if (fabsf(r3[1]) > fabsf(r2[1]))
swap_rows(&r3, &r2);
if (fabsf(r2[1]) > fabsf(r1[1]))
swap_rows(&r2, &r1);
if (r1[1] == 0.0f)
return FALSE;
/* Eliminate second variable. */
m2 = r2[1] / r1[1]; m3 = r3[1] / r1[1];
r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
s = r1[4];
if (s != 0.0f)
{
r2[4] -= m2 * s;
r3[4] -= m3 * s;
}
s = r1[5];
if (s != 0.0f)
{
r2[5] -= m2 * s;
r3[5] -= m3 * s;
}
s = r1[6];
if (s != 0.0f)
{
r2[6] -= m2 * s;
r3[6] -= m3 * s;
}
s = r1[7];
if (s != 0.0f)
{
r2[7] -= m2 * s;
r3[7] -= m3 * s;
}
/* Choose pivot - or die. */
if (fabsf(r3[2]) > fabsf(r2[2]))
swap_rows(&r3, &r2);
if (r2[2] == 0.0f)
return FALSE;
/* Eliminate third variable. */
m3 = r3[2] / r2[2];
r3[3] -= m3 * r2[3];
r3[4] -= m3 * r2[4];
r3[5] -= m3 * r2[5];
r3[6] -= m3 * r2[6];
r3[7] -= m3 * r2[7];
/* Last check. */
if (r3[3] == 0.0f)
return FALSE;
/* Back substitute row 3. */
s = 1.0f / r3[3];
r3[4] *= s;
r3[5] *= s;
r3[6] *= s;
r3[7] *= s;
/* Back substitute row 2. */
m2 = r2[3];
s = 1.0f / r2[2];
r2[4] = s * (r2[4] - r3[4] * m2);
r2[5] = s * (r2[5] - r3[5] * m2);
r2[6] = s * (r2[6] - r3[6] * m2);
r2[7] = s * (r2[7] - r3[7] * m2);
m1 = r1[3];
r1[4] -= r3[4] * m1;
r1[5] -= r3[5] * m1;
r1[6] -= r3[6] * m1;
r1[7] -= r3[7] * m1;
m0 = r0[3];
r0[4] -= r3[4] * m0;
r0[5] -= r3[5] * m0;
r0[6] -= r3[6] * m0;
r0[7] -= r3[7] * m0;
/* Back substitute row 1. */
m1 = r1[2];
s = 1.0f / r1[1];
r1[4] = s * (r1[4] - r2[4] * m1);
r1[5] = s * (r1[5] - r2[5] * m1);
r1[6] = s * (r1[6] - r2[6] * m1);
r1[7] = s * (r1[7] - r2[7] * m1);
m0 = r0[2];
r0[4] -= r2[4] * m0;
r0[5] -= r2[5] * m0;
r0[6] -= r2[6] * m0;
r0[7] -= r2[7] * m0;
/* Back substitute row 0. */
m0 = r0[1];
s = 1.0f / r0[0];
r0[4] = s * (r0[4] - r1[4] * m0);
r0[5] = s * (r0[5] - r1[5] * m0);
r0[6] = s * (r0[6] - r1[6] * m0);
r0[7] = s * (r0[7] - r1[7] * m0);
out->_11 = r0[4];
out->_12 = r0[5];
out->_13 = r0[6];
out->_14 = r0[7];
out->_21 = r1[4];
out->_22 = r1[5];
out->_23 = r1[6];
out->_24 = r1[7];
out->_31 = r2[4];
out->_32 = r2[5];
out->_33 = r2[6];
out->_34 = r2[7];
out->_41 = r3[4];
out->_42 = r3[5];
out->_43 = r3[6];
out->_44 = r3[7];
return TRUE;
}
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) {
DWORD size = 0;
int i;
@ -5896,27 +5734,7 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st
{
switch (texture->target)
{
case GL_TEXTURE_1D:
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable(GL_TEXTURE_2D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable(GL_TEXTURE_3D)");
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
}
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
}
gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_1D);
checkGLcall("glEnable(GL_TEXTURE_1D)");
break;
case GL_TEXTURE_2D:
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable(GL_TEXTURE_3D)");
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
@ -5933,8 +5751,6 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st
checkGLcall("glEnable(GL_TEXTURE_2D)");
break;
case GL_TEXTURE_RECTANGLE_ARB:
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable(GL_TEXTURE_2D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
@ -5958,16 +5774,12 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
}
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable(GL_TEXTURE_2D)");
gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_3D);
checkGLcall("glEnable(GL_TEXTURE_3D)");
break;
case GL_TEXTURE_CUBE_MAP_ARB:
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable(GL_TEXTURE_2D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
@ -5984,8 +5796,6 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st
}
else
{
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_1D);
checkGLcall("glDisable(GL_TEXTURE_1D)");
gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D);
checkGLcall("glEnable(GL_TEXTURE_2D)");
gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D);
@ -6086,14 +5896,6 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
break;
}
if (use_indexed_vertex_blending(state, si))
{
if (use_software_vertex_processing(context->device))
settings->sw_blending = 1;
else
settings->vb_indices = 1;
}
settings->clipping = state->render_states[WINED3D_RS_CLIPPING]
&& state->render_states[WINED3D_RS_CLIPPLANEENABLE];
settings->normal = !!(si->use_map & (1u << WINED3D_FFP_NORMAL));

View file

@ -117,15 +117,6 @@ static BOOL declaration_element_valid_ffp(const struct wined3d_vertex_element *e
return FALSE;
}
case WINED3D_DECL_USAGE_BLEND_INDICES:
switch(element->format)
{
case WINED3DFMT_R8G8B8A8_UINT:
return TRUE;
default:
return FALSE;
}
case WINED3D_DECL_USAGE_NORMAL:
switch(element->format)
{

View file

@ -43,10 +43,6 @@ static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info,
{
{GL_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_CUBE_MAP},
{GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_RECTANGLE},
{GL_TEXTURE_1D, 0, GL_TEXTURE_1D},
{GL_TEXTURE_1D, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_1D_ARRAY},
{GL_TEXTURE_1D_ARRAY, 0, GL_TEXTURE_1D},
{GL_TEXTURE_1D_ARRAY, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_1D_ARRAY},
{GL_TEXTURE_2D, 0, GL_TEXTURE_2D},
{GL_TEXTURE_2D, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_2D_ARRAY},
{GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_2D},
@ -72,7 +68,7 @@ static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info,
}
static const struct wined3d_format *validate_resource_view(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, BOOL mip_slice)
struct wined3d_resource *resource, BOOL mip_slice, BOOL allow_srgb_toggle)
{
const struct wined3d_gl_info *gl_info = &resource->device->adapter->gl_info;
const struct wined3d_format *format;
@ -129,6 +125,14 @@ static const struct wined3d_format *validate_resource_view(const struct wined3d_
struct wined3d_texture *texture = texture_from_resource(resource);
unsigned int depth_or_layer_count;
if (resource->format->id != format->id && !wined3d_format_is_typeless(resource->format)
&& (!allow_srgb_toggle || !wined3d_formats_are_srgb_variants(resource->format->id, format->id)))
{
WARN("Trying to create incompatible view for non typeless format %s.\n",
debug_d3dformat(format->id));
return NULL;
}
if (mip_slice && resource->type == WINED3D_RTYPE_TEXTURE_3D)
depth_or_layer_count = wined3d_texture_get_level_depth(texture, desc->u.texture.level_idx);
else
@ -533,11 +537,20 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *
const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
BOOL allow_srgb_toggle = FALSE;
view->refcount = 1;
view->parent = parent;
view->parent_ops = parent_ops;
if (!(view->format = validate_resource_view(desc, resource, TRUE)))
if (resource->type != WINED3D_RTYPE_BUFFER)
{
struct wined3d_texture *texture = texture_from_resource(resource);
if (texture->swapchain)
allow_srgb_toggle = TRUE;
}
if (!(view->format = validate_resource_view(desc, resource, TRUE, allow_srgb_toggle)))
return E_INVALIDARG;
view->format_flags = view->format->flags[resource->gl_type];
view->desc = *desc;
@ -713,16 +726,16 @@ static void wined3d_shader_resource_view_cs_init(void *object)
{
create_texture_view(&view->gl_view, view_target, desc, texture, view_format);
}
else if (wined3d_format_is_depth_view(resource->format->id, view_format->id))
{
create_texture_view(&view->gl_view, view_target, desc, texture, resource->format);
}
else
{
FIXME("Shader resource view not supported, resource format %s, view format %s.\n",
debug_d3dformat(resource->format->id), debug_d3dformat(view_format->id));
}
}
#if defined(STAGING_CSMT)
wined3d_resource_release(resource);
#endif /* STAGING_CSMT */
}
static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_view *view,
@ -733,15 +746,12 @@ static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_
view->parent = parent;
view->parent_ops = parent_ops;
if (!(view->format = validate_resource_view(desc, resource, FALSE)))
if (!(view->format = validate_resource_view(desc, resource, FALSE, FALSE)))
return E_INVALIDARG;
view->desc = *desc;
wined3d_resource_incref(view->resource = resource);
#if defined(STAGING_CSMT)
wined3d_resource_acquire(resource);
#endif /* STAGING_CSMT */
wined3d_cs_init_object(resource->device->cs, wined3d_shader_resource_view_cs_init, view);
return WINED3D_OK;
@ -799,6 +809,112 @@ void wined3d_shader_resource_view_bind(struct wined3d_shader_resource_view *view
wined3d_sampler_bind(sampler, unit, texture, context);
}
/* Context activation is done by the caller. */
static void shader_resource_view_bind_and_dirtify(struct wined3d_shader_resource_view *view,
struct wined3d_context *context)
{
if (context->active_texture < ARRAY_SIZE(context->rev_tex_unit_map))
{
DWORD active_sampler = context->rev_tex_unit_map[context->active_texture];
if (active_sampler != WINED3D_UNMAPPED_STAGE)
context_invalidate_state(context, STATE_SAMPLER(active_sampler));
}
/* FIXME: Ideally we'd only do this when touching a binding that's used by
* a shader. */
context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
context_bind_texture(context, view->gl_view.target, view->gl_view.name);
}
void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view)
{
struct wined3d_texture *texture = texture_from_resource(view->resource);
unsigned int i, j, layer_count, level_count, base_level, max_level;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
struct gl_texture *gl_tex;
DWORD location;
BOOL srgb;
TRACE("view %p.\n", view);
context = context_acquire(view->resource->device, NULL, 0);
gl_info = context->gl_info;
layer_count = view->desc.u.texture.layer_count;
level_count = view->desc.u.texture.level_count;
base_level = view->desc.u.texture.level_idx;
max_level = base_level + level_count - 1;
srgb = !!(texture->flags & WINED3D_TEXTURE_IS_SRGB);
location = srgb ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB;
for (i = 0; i < layer_count; ++i)
wined3d_texture_load_location(texture, i * level_count + base_level, context, location);
if (view->gl_view.name)
{
shader_resource_view_bind_and_dirtify(view, context);
}
else
{
wined3d_texture_bind_and_dirtify(texture, context, srgb);
gl_info->gl_ops.gl.p_glTexParameteri(texture->target, GL_TEXTURE_BASE_LEVEL, base_level);
gl_info->gl_ops.gl.p_glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, max_level);
}
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
GL_EXTCALL(glBindSampler(context->active_texture, 0));
gl_tex = wined3d_texture_get_gl_texture(texture, srgb);
if (context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
{
gl_info->gl_ops.gl.p_glTexParameteri(texture->target, GL_TEXTURE_SRGB_DECODE_EXT,
GL_SKIP_DECODE_EXT);
gl_tex->sampler_desc.srgb_decode = FALSE;
}
gl_info->fbo_ops.glGenerateMipmap(texture->target);
checkGLcall("glGenerateMipMap()");
for (i = 0; i < layer_count; ++i)
{
for (j = base_level + 1; j <= max_level; ++j)
{
wined3d_texture_validate_location(texture, i * level_count + j, location);
wined3d_texture_invalidate_location(texture, i * level_count + j, ~location);
}
}
if (!view->gl_view.name)
{
gl_tex->base_level = base_level;
gl_info->gl_ops.gl.p_glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, texture->level_count - 1);
}
context_release(context);
}
void CDECL wined3d_shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view)
{
struct wined3d_texture *texture;
TRACE("view %p.\n", view);
if (view->resource->type == WINED3D_RTYPE_BUFFER)
{
WARN("Called on buffer resource %p.\n", view->resource);
return;
}
texture = texture_from_resource(view->resource);
if (!(texture->flags & WINED3D_TEXTURE_GENERATE_MIPMAPS))
{
WARN("Texture without the WINED3D_TEXTURE_GENERATE_MIPMAPS flag, ignoring.\n");
return;
}
wined3d_cs_emit_generate_mipmaps(view->resource->device->cs, view);
}
ULONG CDECL wined3d_unordered_access_view_incref(struct wined3d_unordered_access_view *view)
{
ULONG refcount = InterlockedIncrement(&view->refcount);
@ -988,10 +1104,6 @@ static void wined3d_unordered_access_view_cs_init(void *object)
desc, texture, view->format);
}
}
#if defined(STAGING_CSMT)
wined3d_resource_release(resource);
#endif /* STAGING_CSMT */
}
static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_access_view *view,
@ -1002,15 +1114,12 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces
view->parent = parent;
view->parent_ops = parent_ops;
if (!(view->format = validate_resource_view(desc, resource, TRUE)))
if (!(view->format = validate_resource_view(desc, resource, TRUE, FALSE)))
return E_INVALIDARG;
view->desc = *desc;
wined3d_resource_incref(view->resource = resource);
#if defined(STAGING_CSMT)
wined3d_resource_acquire(resource);
#endif /* STAGING_CSMT */
wined3d_cs_init_object(resource->device->cs, wined3d_unordered_access_view_cs_init, view);
return WINED3D_OK;

View file

@ -221,12 +221,10 @@
@ cdecl wined3d_resource_get_parent(ptr)
@ cdecl wined3d_resource_get_priority(ptr)
@ cdecl wined3d_resource_map(ptr long ptr ptr long)
@ cdecl wined3d_resource_map_info(ptr long ptr long)
@ cdecl wined3d_resource_preload(ptr)
@ cdecl wined3d_resource_set_parent(ptr ptr)
@ cdecl wined3d_resource_set_priority(ptr long)
@ cdecl wined3d_resource_unmap(ptr long)
@ cdecl wined3d_resource_update_info(ptr long ptr long long)
@ cdecl wined3d_rendertarget_view_create(ptr ptr ptr ptr ptr)
@ cdecl wined3d_rendertarget_view_create_from_sub_resource(ptr long ptr ptr ptr)
@ -256,6 +254,7 @@
@ cdecl wined3d_shader_resource_view_create(ptr ptr ptr ptr ptr)
@ cdecl wined3d_shader_resource_view_decref(ptr)
@ cdecl wined3d_shader_resource_view_generate_mipmaps(ptr)
@ cdecl wined3d_shader_resource_view_get_parent(ptr)
@ cdecl wined3d_shader_resource_view_incref(ptr)
@ -265,8 +264,6 @@
@ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_strictdrawing_set(long)
@ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr)
@ cdecl wined3d_swapchain_decref(ptr)
@ cdecl wined3d_swapchain_get_back_buffer(ptr long)
@ -291,7 +288,6 @@
@ cdecl wined3d_texture_create(ptr ptr long long long ptr ptr ptr ptr)
@ cdecl wined3d_texture_decref(ptr)
@ cdecl wined3d_texture_from_resource(ptr)
@ cdecl wined3d_texture_generate_mipmaps(ptr)
@ cdecl wined3d_texture_get_autogen_filter_type(ptr)
@ cdecl wined3d_texture_get_dc(ptr long ptr)
@ cdecl wined3d_texture_get_level_count(ptr)
@ -322,11 +318,3 @@
@ cdecl wined3d_vertex_declaration_decref(ptr)
@ cdecl wined3d_vertex_declaration_get_parent(ptr)
@ cdecl wined3d_vertex_declaration_incref(ptr)
@ cdecl wined3d_dxtn_supported()
@ cdecl wined3d_dxt1_decode(ptr ptr long long long long long)
@ cdecl wined3d_dxt1_encode(ptr ptr long long long long long)
@ cdecl wined3d_dxt3_decode(ptr ptr long long long long long)
@ cdecl wined3d_dxt3_encode(ptr ptr long long long long long)
@ cdecl wined3d_dxt5_decode(ptr ptr long long long long long)
@ cdecl wined3d_dxt5_encode(ptr ptr long long long long long)

View file

@ -25,7 +25,6 @@
#define __WINE_WINED3D_GL_H
#include "wine/wgl.h"
#include "wine/wglext.h"
#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 /* not in the gl spec */
@ -53,9 +52,9 @@ enum wined3d_gl_extension
ARB_CONSERVATIVE_DEPTH,
ARB_COPY_BUFFER,
ARB_COPY_IMAGE,
ARB_CULL_DISTANCE,
ARB_DEBUG_OUTPUT,
ARB_DEPTH_BUFFER_FLOAT,
ARB_DEPTH_CLAMP,
ARB_DEPTH_TEXTURE,
ARB_DERIVATIVE_CONTROL,
ARB_DRAW_BUFFERS,
@ -113,6 +112,7 @@ enum wined3d_gl_extension
ARB_TEXTURE_CUBE_MAP_ARRAY,
ARB_TEXTURE_ENV_COMBINE,
ARB_TEXTURE_ENV_DOT3,
ARB_TEXTURE_FILTER_ANISOTROPIC,
ARB_TEXTURE_FLOAT,
ARB_TEXTURE_GATHER,
ARB_TEXTURE_MIRRORED_REPEAT,
@ -169,7 +169,6 @@ enum wined3d_gl_extension
EXT_TEXTURE_COMPRESSION_S3TC,
EXT_TEXTURE_ENV_COMBINE,
EXT_TEXTURE_ENV_DOT3,
EXT_TEXTURE_FILTER_ANISOTROPIC,
EXT_TEXTURE_INTEGER,
EXT_TEXTURE_LOD_BIAS,
EXT_TEXTURE_MIRROR_CLAMP,
@ -198,7 +197,6 @@ enum wined3d_gl_extension
NV_VERTEX_PROGRAM2,
NV_VERTEX_PROGRAM2_OPTION,
NV_VERTEX_PROGRAM3,
NVX_GPU_MEMORY_INFO,
/* SGI */
SGIS_GENERATE_MIPMAP,
/* WGL extensions */

View file

@ -70,11 +70,8 @@ static CRITICAL_SECTION wined3d_wndproc_cs = {&wined3d_wndproc_cs_debug, -1, 0,
* where appropriate. */
struct wined3d_settings wined3d_settings =
{
#if !defined(STAGING_CSMT)
FALSE, /* No multithreaded CS by default. */
#else /* STAGING_CSMT */
TRUE, /* Multithreaded CS by default. */
#endif /* STAGING_CSMT */
FALSE, /* explicit_gl_version */
MAKEDWORD_VERSION(1, 0), /* Default to legacy OpenGL */
TRUE, /* Use of GLSL enabled by default */
ORM_FBO, /* Use FBOs to do offscreen rendering */
@ -217,12 +214,10 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
ERR_(winediag)("Setting multithreaded command stream to %#x.\n", wined3d_settings.cs_multithreaded);
if (!get_config_key_dword(hkey, appkey, "MaxVersionGL", &tmpvalue))
{
if (tmpvalue != wined3d_settings.max_gl_version)
{
ERR_(winediag)("Setting maximum allowed wined3d GL version to %u.%u.\n",
tmpvalue >> 16, tmpvalue & 0xffff);
wined3d_settings.max_gl_version = tmpvalue;
}
ERR_(winediag)("Setting maximum allowed wined3d GL version to %u.%u.\n",
tmpvalue >> 16, tmpvalue & 0xffff);
wined3d_settings.explicit_gl_version = TRUE;
wined3d_settings.max_gl_version = tmpvalue;
}
if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) )
{
@ -326,8 +321,6 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
if (appkey) RegCloseKey( appkey );
if (hkey) RegCloseKey( hkey );
wined3d_dxtn_init();
return TRUE;
}
@ -359,9 +352,6 @@ static BOOL wined3d_dll_destroy(HINSTANCE hInstDLL)
DeleteCriticalSection(&wined3d_wndproc_cs);
DeleteCriticalSection(&wined3d_cs);
wined3d_dxtn_free();
return TRUE;
}
@ -516,11 +506,6 @@ void wined3d_unregister_window(HWND window)
wined3d_wndproc_mutex_unlock();
}
void CDECL wined3d_strictdrawing_set(int value)
{
wined3d_settings.strict_draw_ordering = value;
}
/* At process attach */
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
{

View file

@ -72,6 +72,8 @@
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
#endif
#define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
/* Driver quirks */
#define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
#define WINED3D_QUIRK_SET_TEXCOORD_W 0x00000002
@ -202,7 +204,6 @@ struct wined3d_d3d_info
BOOL vs_clipping;
BOOL shader_color_key;
DWORD valid_rt_mask;
DWORD valid_dual_rt_mask;
DWORD wined3d_creation_flags;
BOOL shader_double_precision;
};
@ -276,16 +277,14 @@ static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup
#define MAX_VERTEX_SAMPLERS 4
#define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS)
#define MAX_ACTIVE_LIGHTS 8
#define MAX_CLIP_DISTANCES WINED3DMAXUSERCLIPPLANES
#define MAX_CLIP_DISTANCES 8
#define MAX_CONSTANT_BUFFERS 15
#define MAX_SAMPLER_OBJECTS 16
#define MAX_SHADER_RESOURCE_VIEWS 128
#define MAX_UNORDERED_ACCESS_VIEWS 8
#define MAX_TGSM_REGISTERS 8192
#define MAX_VERTEX_BLENDS 4
#define MAX_VERTEX_INDEX_BLENDS 9
#define MAX_MULTISAMPLE_TYPES 8
#define MAX_RENDER_TARGETS 8
struct min_lookup
{
@ -394,6 +393,7 @@ static inline void wined3d_pause(void)
struct wined3d_settings
{
unsigned int cs_multithreaded;
BOOL explicit_gl_version;
DWORD max_gl_version;
BOOL glslRequested;
int offscreen_rendering_mode;
@ -446,14 +446,13 @@ enum wined3d_shader_resource_type
#define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
#define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
#define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
#define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
#define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
#define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
#define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
#define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
#define WINED3D_SHADER_CONST_FFP_PS 0x00100000
#define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
#define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0xff000000
#define WINED3D_SHADER_CONST_FFP_VERTEXBLEND_INDEX(i) (0x01000000 << ((i) - 1))
enum wined3d_shader_register_type
{
@ -505,8 +504,8 @@ enum wined3d_shader_register_type
WINED3DSPR_COVERAGE,
WINED3DSPR_SAMPLEMASK,
WINED3DSPR_GSINSTID,
WINED3DSPR_DEPTHOUT_GREATER_EQUAL,
WINED3DSPR_DEPTHOUT_LESS_EQUAL,
WINED3DSPR_DEPTHOUTGE,
WINED3DSPR_DEPTHOUTLE,
};
enum wined3d_data_type
@ -564,6 +563,7 @@ enum wined3d_shader_dst_modifier
enum wined3d_shader_interpolation_mode
{
WINED3DSIM_NONE = 0,
WINED3DSIM_CONSTANT = 1,
WINED3DSIM_LINEAR = 2,
WINED3DSIM_LINEAR_CENTROID = 3,
@ -573,6 +573,9 @@ enum wined3d_shader_interpolation_mode
WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7,
};
#define WINED3D_PACKED_INTERPOLATION_SIZE 3
#define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
enum wined3d_shader_global_flags
{
WINED3DSGF_REFACTORING_ALLOWED = 0x1,
@ -769,6 +772,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_DSY,
WINED3DSIH_DSY_COARSE,
WINED3DSIH_DSY_FINE,
WINED3DSIH_EVAL_SAMPLE_INDEX,
WINED3DSIH_ELSE,
WINED3DSIH_EMIT,
WINED3DSIH_EMIT_STREAM,
@ -1013,31 +1017,34 @@ struct wined3d_shader_reg_maps
BYTE bumpmat; /* MAX_TEXTURES, 8 */
BYTE luminanceparams; /* MAX_TEXTURES, 8 */
struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
DWORD uav_read_mask; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
DWORD uav_counter_mask; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
DWORD uav_read_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
WORD usesnrm : 1;
WORD vpos : 1;
WORD usesdsx : 1;
WORD usesdsy : 1;
WORD usestexldd : 1;
WORD usesmova : 1;
WORD usesfacing : 1;
WORD usesrelconstF : 1;
WORD fog : 1;
WORD usestexldl : 1;
WORD usesifc : 1;
WORD usescall : 1;
WORD usespow : 1;
WORD point_size : 1;
WORD vocp : 1;
WORD padding : 1;
DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
DWORD cull_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
DWORD usesnrm : 1;
DWORD vpos : 1;
DWORD usesdsx : 1;
DWORD usesdsy : 1;
DWORD usestexldd : 1;
DWORD usesmova : 1;
DWORD usesfacing : 1;
DWORD usesrelconstF : 1;
DWORD fog : 1;
DWORD usestexldl : 1;
DWORD usesifc : 1;
DWORD usescall : 1;
DWORD usespow : 1;
DWORD point_size : 1;
DWORD vocp : 1;
DWORD input_rel_addressing : 1;
DWORD padding : 16;
DWORD rt_mask; /* Used render targets, 32 max. */
/* Whether or not loops are used in this shader, and nesting depth */
unsigned loop_depth;
UINT min_rel_offset, max_rel_offset;
unsigned int loop_depth;
unsigned int min_rel_offset, max_rel_offset;
struct wined3d_shader_tgsm *tgsm;
SIZE_T tgsm_capacity;
@ -1337,7 +1344,8 @@ enum wined3d_shader_tex_types
WINED3D_SHADER_TEX_CUBE = 2,
};
struct ps_compile_args {
struct ps_compile_args
{
struct color_fixup_desc color_fixup[MAX_FRAGMENT_SAMPLERS];
enum vertexprocessing_mode vp_mode;
enum wined3d_ffp_ps_fog_mode fog;
@ -1354,11 +1362,11 @@ struct ps_compile_args {
DWORD flatshading : 1;
DWORD alpha_test_func : 3;
DWORD render_offscreen : 1;
DWORD dual_source_blend : 1;
DWORD padding : 25;
DWORD padding : 26;
};
enum fog_src_type {
enum fog_src_type
{
VS_FOG_Z = 0,
VS_FOG_COORD = 1
};
@ -1374,6 +1382,7 @@ struct vs_compile_args
BYTE padding : 1;
WORD swizzle_map; /* MAX_ATTRIBS, 16 */
unsigned int next_shader_input_count;
DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
};
struct ds_compile_args
@ -1384,11 +1393,13 @@ struct ds_compile_args
unsigned int next_shader_type : 3;
unsigned int render_offscreen : 1;
unsigned int padding : 12;
DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
};
struct gs_compile_args
{
unsigned int output_count;
DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
};
struct wined3d_context;
@ -1497,6 +1508,29 @@ void wined3d_stream_info_from_declaration(struct wined3d_stream_info *stream_inf
const struct wined3d_state *state, const struct wined3d_gl_info *gl_info,
const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
struct wined3d_direct_dispatch_parameters
{
unsigned int group_count_x;
unsigned int group_count_y;
unsigned int group_count_z;
};
struct wined3d_indirect_dispatch_parameters
{
struct wined3d_buffer *buffer;
unsigned int offset;
};
struct wined3d_dispatch_parameters
{
BOOL indirect;
union
{
struct wined3d_direct_dispatch_parameters direct;
struct wined3d_indirect_dispatch_parameters indirect;
} u;
};
struct wined3d_direct_draw_parameters
{
int base_vertex_idx;
@ -1523,29 +1557,6 @@ struct wined3d_draw_parameters
BOOL indexed;
};
struct wined3d_direct_dispatch_parameters
{
unsigned int group_count_x;
unsigned int group_count_y;
unsigned int group_count_z;
};
struct wined3d_indirect_dispatch_parameters
{
struct wined3d_buffer *buffer;
unsigned int offset;
};
struct wined3d_dispatch_parameters
{
BOOL indirect;
union
{
struct wined3d_direct_dispatch_parameters direct;
struct wined3d_indirect_dispatch_parameters indirect;
} u;
};
void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
const struct wined3d_draw_parameters *draw_parameters) DECLSPEC_HIDDEN;
void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state,
@ -1872,6 +1883,7 @@ struct wined3d_context
/* Stores some information about the context state for optimization */
DWORD render_offscreen : 1;
DWORD last_was_rhw : 1; /* true iff last draw_primitive was in xyzrhw mode */
DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
DWORD last_was_pshader : 1;
DWORD last_was_vshader : 1;
DWORD last_was_normal : 1;
@ -1902,10 +1914,9 @@ struct wined3d_context
DWORD destroy_delayed : 1;
DWORD transform_feedback_active : 1;
DWORD transform_feedback_paused : 1;
DWORD last_was_dual_blend : 1;
DWORD padding : 6;
DWORD last_swizzle_map; /* MAX_ATTRIBS, 16 */
DWORD shader_update_mask;
DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
DWORD padding : 9;
DWORD constant_update_mask;
DWORD numbered_array_mask;
GLenum tracking_parm; /* Which source is tracking current colour */
@ -2089,6 +2100,7 @@ enum wined3d_blit_op
WINED3D_BLIT_OP_COLOR_FILL,
WINED3D_BLIT_OP_DEPTH_FILL,
WINED3D_BLIT_OP_DEPTH_BLIT,
WINED3D_BLIT_OP_RAW_BLIT,
};
struct wined3d_blitter
@ -2103,7 +2115,7 @@ struct wined3d_blitter_ops
void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
void (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect,
struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter);
@ -2116,6 +2128,8 @@ void wined3d_fbo_blitter_create(struct wined3d_blitter **next,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
void wined3d_ffp_blitter_create(struct wined3d_blitter **next,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
void wined3d_raw_blitter_create(struct wined3d_blitter **next,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
@ -2147,6 +2161,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, stru
const struct wined3d_format *ds_format) DECLSPEC_HIDDEN;
HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
void context_destroy(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
void context_enable_clip_distances(struct wined3d_context *context, unsigned int mask) DECLSPEC_HIDDEN;
void context_end_transform_feedback(struct wined3d_context *context) DECLSPEC_HIDDEN;
void context_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
@ -2337,7 +2352,6 @@ enum wined3d_pci_device
CARD_NVIDIA_GEFORCE_GTX550 = 0x1244,
CARD_NVIDIA_GEFORCE_GT555M = 0x04b8,
CARD_NVIDIA_GEFORCE_GTX560TI = 0x1200,
CARD_NVIDIA_GEFORCE_GTX560M = 0x1251,
CARD_NVIDIA_GEFORCE_GTX560 = 0x1201,
CARD_NVIDIA_GEFORCE_GTX570 = 0x1081,
CARD_NVIDIA_GEFORCE_GTX580 = 0x1080,
@ -2435,6 +2449,7 @@ enum wined3d_pci_device
CARD_INTEL_IVBS = 0x015a,
CARD_INTEL_HWD = 0x0412,
CARD_INTEL_HWM = 0x0416,
CARD_INTEL_HD5000 = 0x0a26,
CARD_INTEL_I5100_1 = 0x0a22,
CARD_INTEL_I5100_2 = 0x0a2a,
CARD_INTEL_I5100_3 = 0x0a2b,
@ -2508,7 +2523,6 @@ struct wined3d_fbo_ops
struct wined3d_gl_limits
{
UINT buffers;
UINT dual_buffers;
UINT lights;
UINT textures;
UINT texture_coords;
@ -2559,7 +2573,6 @@ struct wined3d_gl_info
DWORD quirks;
BOOL supported[WINED3D_GL_EXT_COUNT];
GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
float fixed_polyoffset_scale, float_polyoffset_scale;
HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
struct opengl_funcs gl_ops;
@ -2615,7 +2628,6 @@ struct wined3d_caps_gl_ctx
GLuint test_program_id;
};
float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *ctx, GLenum format) DECLSPEC_HIDDEN;
BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter,
struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
@ -2736,8 +2748,7 @@ struct wined3d_ffp_vs_settings
DWORD ortho_fog : 1;
DWORD flatshading : 1;
DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
DWORD vb_indices : 1;
DWORD sw_blending : 1;
DWORD padding : 2;
DWORD texgen[MAX_TEXTURES];
};
@ -2844,32 +2855,6 @@ struct wined3d_state
struct wined3d_rasterizer_state *rasterizer_state;
};
static inline BOOL wined3d_dualblend_enabled(const struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
{
if (!state->fb->render_targets[0]) return FALSE;
if (!state->render_states[WINED3D_RS_ALPHABLENDENABLE]) return FALSE;
if (!gl_info->supported[ARB_BLEND_FUNC_EXTENDED]) return FALSE;
#define IS_DUAL_SOURCE_BLEND(x) ((x) >= WINED3D_BLEND_SRC1COLOR && (x) <= WINED3D_BLEND_INVSRC1ALPHA)
if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_SRCBLEND])) return TRUE;
if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_DESTBLEND])) return TRUE;
if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_SRCBLENDALPHA])) return TRUE;
if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_DESTBLENDALPHA])) return TRUE;
#undef IS_DUAL_SOURCE_BLEND
return FALSE;
}
#if defined(STAGING_CSMT)
struct wined3d_gl_bo
{
GLuint name;
GLenum usage;
GLenum type_hint;
UINT size;
};
#endif /* STAGING_CSMT */
#define WINED3D_UNMAPPED_STAGE ~0u
/* Multithreaded flag. Removed from the public header to signal that
@ -2945,13 +2930,11 @@ struct wined3d_device
/* Textures for when no other textures are mapped */
struct
{
GLuint tex_1d;
GLuint tex_2d;
GLuint tex_rect;
GLuint tex_3d;
GLuint tex_cube;
GLuint tex_cube_array;
GLuint tex_1d_array;
GLuint tex_2d_array;
GLuint tex_buffer;
} dummy_textures;
@ -2981,12 +2964,6 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
#if defined(STAGING_CSMT)
struct wined3d_gl_bo *wined3d_device_get_bo(struct wined3d_device *device, UINT size, GLenum gl_usage,
GLenum type_hint, struct wined3d_context *context) DECLSPEC_HIDDEN;
void wined3d_device_release_bo(struct wined3d_device *device, struct wined3d_gl_bo *bo,
const struct wined3d_context *context) DECLSPEC_HIDDEN;
#endif /* STAGING_CSMT */
static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
{
@ -3006,8 +2983,6 @@ struct wined3d_resource_ops
void (*resource_unload)(struct wined3d_resource *resource);
HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
HRESULT (*resource_map_info)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_info *info, DWORD flags);
HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
};
@ -3116,6 +3091,7 @@ struct wined3d_texture_ops
#define WINED3D_TEXTURE_DC_IN_USE 0x00001000
#define WINED3D_TEXTURE_DISCARD 0x00002000
#define WINED3D_TEXTURE_GET_DC 0x00004000
#define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
#define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
@ -3174,11 +3150,7 @@ struct wined3d_texture
unsigned int map_count;
DWORD locations;
#if !defined(STAGING_CSMT)
GLuint buffer_object;
#else /* STAGING_CSMT */
struct wined3d_gl_bo *buffer;
#endif /* STAGING_CSMT */
} sub_resources[1];
};
@ -3397,7 +3369,7 @@ struct wined3d_saved_states
DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1];
DWORD textureState[MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */
DWORD clipplane; /* WINED3D_MAX_USER_CLIP_PLANES, 32 */
WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
BOOL ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
@ -3493,9 +3465,6 @@ struct wined3d_cs_queue
struct wined3d_cs_ops
{
#if defined(STAGING_CSMT)
BOOL (*check_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id);
#endif /* STAGING_CSMT */
void *(*require_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id);
void (*submit)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
void (*finish)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
@ -3517,6 +3486,7 @@ struct wined3d_cs
size_t data_size, start, end;
void *data;
struct list query_poll_list;
BOOL queries_flushed;
HANDLE event;
BOOL waiting_for_event;
@ -3551,6 +3521,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned
void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
struct wined3d_buffer *buffer, unsigned int offset, BOOL indexed) DECLSPEC_HIDDEN;
void wined3d_cs_emit_flush(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
void wined3d_cs_emit_generate_mipmaps(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain,
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD flags) DECLSPEC_HIDDEN;
@ -3607,9 +3578,6 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou
void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
unsigned int slice_pitch) DECLSPEC_HIDDEN;
void wined3d_cs_emit_copy_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource,
unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource,
unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) DECLSPEC_HIDDEN;
void wined3d_cs_init_object(struct wined3d_cs *cs,
void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, unsigned int sub_resource_idx,
@ -3690,7 +3658,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN;
void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer,
void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN;
struct wined3d_rendertarget_view
@ -3751,6 +3719,7 @@ struct wined3d_shader_resource_view
struct wined3d_view_desc desc;
};
void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
void wined3d_shader_resource_view_bind(struct wined3d_shader_resource_view *view, unsigned int unit,
struct wined3d_sampler *sampler, struct wined3d_context *context) DECLSPEC_HIDDEN;
@ -3901,8 +3870,6 @@ GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) DE
/* Math utils */
void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
const struct wined3d_matrix *src2) DECLSPEC_HIDDEN;
BOOL invert_matrix_3d(struct wined3d_matrix *out, const struct wined3d_matrix *in) DECLSPEC_HIDDEN;
BOOL invert_matrix(struct wined3d_matrix *out, struct wined3d_matrix *m) DECLSPEC_HIDDEN;
void wined3d_release_dc(HWND window, HDC dc) DECLSPEC_HIDDEN;
@ -4001,7 +3968,8 @@ struct wined3d_pixel_shader
DWORD color0_reg;
BOOL force_early_depth_stencil;
DWORD depth_compare;
enum wined3d_shader_register_type depth_output;
DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
};
struct wined3d_compute_shader
@ -4062,13 +4030,13 @@ BOOL vshader_get_input(const struct wined3d_shader *shader,
BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
WORD swizzle_map, struct vs_compile_args *args,
const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
const struct wined3d_context *context) DECLSPEC_HIDDEN;
void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
struct ds_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
struct gs_compile_args *args) DECLSPEC_HIDDEN;
struct gs_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
void string_buffer_clear(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
BOOL string_buffer_init(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
@ -4092,8 +4060,8 @@ static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
return FALSE;
case WINED3DSPR_DEPTHOUT: /* oDepth */
case WINED3DSPR_DEPTHOUT_GREATER_EQUAL:
case WINED3DSPR_DEPTHOUT_LESS_EQUAL:
case WINED3DSPR_DEPTHOUTGE:
case WINED3DSPR_DEPTHOUTLE:
case WINED3DSPR_CONSTBOOL: /* b# */
case WINED3DSPR_LOOP: /* aL */
case WINED3DSPR_PREDICATE: /* p0 */
@ -4214,6 +4182,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
#define WINED3DFMT_FLAG_DEPTH 0x00000004
#define WINED3DFMT_FLAG_STENCIL 0x00000008
#define WINED3DFMT_FLAG_RENDERTARGET 0x00000010
#define WINED3DFMT_FLAG_EXTENSION 0x00000020
#define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x00000040
#define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB 0x00000080
#define WINED3DFMT_FLAG_FLOAT 0x00000200
@ -4279,10 +4248,15 @@ struct wined3d_format
UINT conv_byte_count;
DWORD multisample_types;
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
float depth_bias_scale;
struct wined3d_rational height_scale;
struct color_fixup_desc color_fixup;
void (*convert)(const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch,
UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth);
void (*upload)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
unsigned int dst_row_pitch, unsigned dst_slice_pitch,
unsigned int width, unsigned int height, unsigned int depth);
void (*download)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
unsigned int dst_row_pitch, unsigned dst_slice_pitch,
unsigned int width, unsigned int height, unsigned int depth);
enum wined3d_format_id typeless_id;
GLenum gl_view_class;
@ -4298,8 +4272,12 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
const struct wined3d_color *color) DECLSPEC_HIDDEN;
void wined3d_format_get_float_color_key(const struct wined3d_format *format,
const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1,
enum wined3d_format_id format2) DECLSPEC_HIDDEN;
BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
@ -4315,34 +4293,6 @@ static inline void *wined3d_calloc(SIZE_T count, SIZE_T size)
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * size);
}
static inline BOOL use_indexed_vertex_blending(const struct wined3d_state *state, const struct wined3d_stream_info *si)
{
if (!state->render_states[WINED3D_RS_INDEXEDVERTEXBLENDENABLE])
return FALSE;
if (state->render_states[WINED3D_RS_VERTEXBLEND] == WINED3D_VBF_DISABLE)
return FALSE;
if (!(si->use_map & (1 << WINED3D_FFP_BLENDINDICES)) || !(si->use_map & (1 << WINED3D_FFP_BLENDWEIGHT)))
return FALSE;
return TRUE;
}
static inline BOOL use_software_vertex_processing(const struct wined3d_device *device)
{
if (device->shader_backend != &glsl_shader_backend)
return FALSE;
if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING)
return TRUE;
if (!(device->create_parms.flags & WINED3DCREATE_MIXED_VERTEXPROCESSING))
return FALSE;
return device->softwareVertexProcessing;
}
static inline BOOL use_vs(const struct wined3d_state *state)
{
/* Check state->vertex_declaration to allow this to be used before the
@ -4396,6 +4346,59 @@ static inline BOOL can_use_texture_swizzle(const struct wined3d_gl_info *gl_info
&& !is_scaling_fixup(format->color_fixup);
}
static inline BOOL needs_interpolation_qualifiers_for_shader_outputs(const struct wined3d_gl_info *gl_info)
{
/* In GLSL 4.40+ it is fine to specify interpolation qualifiers only in
* fragment shaders. In older GLSL versions interpolation qualifiers must
* match between shader stages.
*/
return gl_info->glsl_version < MAKEDWORD_VERSION(4, 40);
}
static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader)
{
return geometry_shader
&& geometry_shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM;
}
static inline DWORD wined3d_extract_bits(const DWORD *bitstream,
unsigned int offset, unsigned int count)
{
const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
const unsigned int idx = offset / word_bit_count;
const unsigned int shift = offset % word_bit_count;
DWORD mask = (1u << count) - 1;
DWORD ret;
ret = (bitstream[idx] >> shift) & mask;
if (shift + count > word_bit_count)
{
const unsigned int extracted_bit_count = word_bit_count - shift;
const unsigned int remaining_bit_count = count - extracted_bit_count;
mask = (1u << remaining_bit_count) - 1;
ret |= (bitstream[idx + 1] & mask) << extracted_bit_count;
}
return ret;
}
static inline void wined3d_insert_bits(DWORD *bitstream,
unsigned int offset, unsigned int count, DWORD bits)
{
const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
const unsigned int idx = offset / word_bit_count;
const unsigned int shift = offset % word_bit_count;
DWORD mask = (1u << count) - 1;
bitstream[idx] |= (bits & mask) << shift;
if (shift + count > word_bit_count)
{
const unsigned int inserted_bit_count = word_bit_count - shift;
const unsigned int remaining_bit_count = count - inserted_bit_count;
mask = (1u << remaining_bit_count) - 1;
bitstream[idx + 1] |= (bits >> inserted_bit_count) & mask;
}
}
static inline struct wined3d_surface *context_get_rt_surface(const struct wined3d_context *context)
{
struct wined3d_texture *texture = context->current_rt.texture;
@ -4416,12 +4419,7 @@ static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
assert(cs->thread_id != GetCurrentThreadId());
}
BOOL wined3d_dxtn_init(void) DECLSPEC_HIDDEN;
void wined3d_dxtn_free(void) DECLSPEC_HIDDEN;
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
#define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
#endif

View file

@ -23,7 +23,7 @@ The following libraries are shared with Wine.
reactos/dll/directx/wine/amstream # Synced to Wine-3.0
reactos/dll/directx/wine/d3d8 # Synced to Wine-3.0
reactos/dll/directx/wine/d3d9 # Synced to WineStaging-2.16
reactos/dll/directx/wine/d3d9 # Synced to Wine-3.0
reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-2.16
reactos/dll/directx/wine/d3drm # Synced to WineStaging-2.16
reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-2.16
@ -40,7 +40,7 @@ reactos/dll/directx/wine/dxdiagn # Synced to WineStaging-2.9
reactos/dll/directx/wine/msdmo # Synced to WineStaging-2.9
reactos/dll/directx/wine/qedit # Synced to WineStaging-2.9
reactos/dll/directx/wine/quartz # Synced to WineStaging-2.16
reactos/dll/directx/wine/wined3d # Synced to WineStaging-2.16
reactos/dll/directx/wine/wined3d # Synced to Wine-3.0
reactos/dll/win32/activeds # Synced to WineStaging-2.9
reactos/dll/win32/actxprxy # Synced to WineStaging-2.9

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -381,21 +381,8 @@ enum wined3d_render_state
WINED3D_RS_SRCBLENDALPHA = 207,
WINED3D_RS_DESTBLENDALPHA = 208,
WINED3D_RS_BLENDOPALPHA = 209,
WINED3D_RS_DEPTHCLIP = 210,
WINED3D_RS_COLORWRITEENABLE4 = 211,
WINED3D_RS_COLORWRITEENABLE5 = 212,
WINED3D_RS_COLORWRITEENABLE6 = 213,
WINED3D_RS_COLORWRITEENABLE7 = 214,
};
#define WINEHIGHEST_RENDER_STATE WINED3D_RS_COLORWRITEENABLE7
static inline enum wined3d_render_state WINED3D_RS_COLORWRITE(int index)
{
if (index == 0) return WINED3D_RS_COLORWRITEENABLE;
if (index <= 3) return WINED3D_RS_COLORWRITEENABLE1 + index - 1;
if (index <= 7) return WINED3D_RS_COLORWRITEENABLE4 + index - 4;
return WINED3D_RS_COLORWRITEENABLE;
}
#define WINEHIGHEST_RENDER_STATE WINED3D_RS_BLENDOPALPHA
enum wined3d_blend
{
@ -685,9 +672,8 @@ enum wined3d_resource_type
{
WINED3D_RTYPE_NONE = 0,
WINED3D_RTYPE_BUFFER = 1,
WINED3D_RTYPE_TEXTURE_1D = 2,
WINED3D_RTYPE_TEXTURE_2D = 3,
WINED3D_RTYPE_TEXTURE_3D = 4,
WINED3D_RTYPE_TEXTURE_2D = 2,
WINED3D_RTYPE_TEXTURE_3D = 3,
};
enum wined3d_pool
@ -942,7 +928,6 @@ enum wined3d_shader_byte_code_format
#define WINED3DPRESENT_INTERVAL_FOUR 0x00000008
#define WINED3DPRESENT_INTERVAL_IMMEDIATE 0x80000000
#define WINED3DMAXUSERCLIPPLANES 32
#define WINED3DCLIPPLANE0 (1u << 0)
#define WINED3DCLIPPLANE1 (1u << 1)
#define WINED3DCLIPPLANE2 (1u << 2)
@ -1321,9 +1306,7 @@ enum wined3d_shader_byte_code_format
#define WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR 0x00000400
#define WINED3D_NO_PRIMITIVE_RESTART 0x00000800
#define WINED3D_LEGACY_CUBEMAP_FILTERING 0x00001000
#define WINED3D_FORWARD_DEPTH_BIAS 0x00002000
#define WINED3D_REQUEST_D3D10 0x00004000
#define WINED3D_LIMIT_VIEWPORT 0x00008000
#define WINED3D_NORMALIZED_DEPTH_BIAS 0x00002000
#define WINED3D_RESZ_CODE 0x7fa05000
@ -1359,6 +1342,7 @@ enum wined3d_shader_byte_code_format
#define WINED3D_BLT_SRC_CKEY_OVERRIDE 0x00010000
#define WINED3D_BLT_WAIT 0x01000000
#define WINED3D_BLT_DO_NOT_WAIT 0x08000000
#define WINED3D_BLT_RAW 0x20000000
#define WINED3D_BLT_SYNCHRONOUS 0x40000000
#define WINED3D_BLT_ALPHA_TEST 0x80000000
#define WINED3D_BLT_MASK 0x0901e800
@ -1554,6 +1538,7 @@ enum wined3d_shader_byte_code_format
#define WINED3D_TEXTURE_CREATE_DISCARD 0x00000002
#define WINED3D_TEXTURE_CREATE_GET_DC_LENIENT 0x00000004
#define WINED3D_TEXTURE_CREATE_GET_DC 0x00000008
#define WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS 0x00000010
#define WINED3D_APPEND_ALIGNED_ELEMENT 0xffffffff
@ -1813,13 +1798,6 @@ struct wined3d_map_desc
void *data;
};
struct wined3d_map_info
{
UINT row_pitch;
UINT slice_pitch;
UINT size;
};
struct wined3d_sub_resource_data
{
const void *data;
@ -2583,14 +2561,10 @@ void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resour
DWORD __cdecl wined3d_resource_get_priority(const struct wined3d_resource *resource);
HRESULT __cdecl wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
HRESULT __cdecl wined3d_resource_map_info(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_info *info, DWORD flags);
void __cdecl wined3d_resource_preload(struct wined3d_resource *resource);
void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent);
DWORD __cdecl wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority);
HRESULT __cdecl wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx);
UINT __cdecl wined3d_resource_update_info(struct wined3d_resource *resource, unsigned int sub_resource_idx,
const struct wined3d_box *box, unsigned int row_pitch, unsigned int depth_pitch);
HRESULT __cdecl wined3d_rendertarget_view_create(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
@ -2636,6 +2610,7 @@ HRESULT __cdecl wined3d_shader_resource_view_create(const struct wined3d_view_de
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_shader_resource_view **view);
ULONG __cdecl wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view);
void __cdecl wined3d_shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view);
void * __cdecl wined3d_shader_resource_view_get_parent(const struct wined3d_shader_resource_view *view);
ULONG __cdecl wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view);
@ -2688,7 +2663,6 @@ HRESULT __cdecl wined3d_texture_create(struct wined3d_device *device, const stru
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
struct wined3d_texture * __cdecl wined3d_texture_from_resource(struct wined3d_resource *resource);
ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture);
void __cdecl wined3d_texture_generate_mipmaps(struct wined3d_texture *texture);
enum wined3d_texture_filter_type __cdecl wined3d_texture_get_autogen_filter_type(const struct wined3d_texture *texture);
HRESULT __cdecl wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC *dc);
DWORD __cdecl wined3d_texture_get_level_count(const struct wined3d_texture *texture);
@ -2780,18 +2754,4 @@ static inline void wined3d_box_set(struct wined3d_box *box, unsigned int left, u
box->back = back;
}
BOOL wined3d_dxt1_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
enum wined3d_format_id format, unsigned int w, unsigned int h);
BOOL wined3d_dxt1_encode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
enum wined3d_format_id format, unsigned int w, unsigned int h);
BOOL wined3d_dxt3_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
enum wined3d_format_id format, unsigned int w, unsigned int h);
BOOL wined3d_dxt3_encode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
enum wined3d_format_id format, unsigned int w, unsigned int h);
BOOL wined3d_dxt5_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
enum wined3d_format_id format, unsigned int w, unsigned int h);
BOOL wined3d_dxt5_encode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
enum wined3d_format_id format, unsigned int w, unsigned int h);
BOOL wined3d_dxtn_supported(void);
#endif /* __WINE_WINED3D_H */