Commit 3c0ed9ce authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Introduce resource-type specific format flags.

parent 53ff2a9d
......@@ -1145,9 +1145,8 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
return WINED3DERR_INVALIDCALL;
}
hr = resource_init(&buffer->resource, device, WINED3D_RTYPE_BUFFER, format,
WINED3D_MULTISAMPLE_NONE, 0, usage, pool, size, 1, 1, size,
parent, parent_ops, &buffer_resource_ops);
hr = resource_init(&buffer->resource, device, WINED3D_RTYPE_BUFFER, WINED3D_GL_RES_TYPE_BUFFER, format,
WINED3D_MULTISAMPLE_NONE, 0, usage, pool, size, 1, 1, size, parent, parent_ops, &buffer_resource_ops);
if (FAILED(hr))
{
WARN("Failed to initialize resource, hr %#x\n", hr);
......
......@@ -2195,8 +2195,11 @@ static BOOL match_depth_stencil_format(const struct wined3d_format *existing,
{
BYTE existing_depth, existing_stencil, required_depth, required_stencil;
if (existing == required) return TRUE;
if ((existing->flags & WINED3DFMT_FLAG_FLOAT) != (required->flags & WINED3DFMT_FLAG_FLOAT)) return FALSE;
if (existing == required)
return TRUE;
if ((existing->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
!= (required->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT))
return FALSE;
getDepthStencilBits(existing, &existing_depth, &existing_stencil);
getDepthStencilBits(required, &required_depth, &required_stencil);
......
......@@ -4095,7 +4095,8 @@ static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_in
BYTE redSize, greenSize, blueSize, alphaSize, colorBits;
/* Float formats need FBOs. If FBOs are used this function isn't called */
if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
return FALSE;
if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
if (!getColorBits(format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
......@@ -4136,7 +4137,8 @@ static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_in
}
/* Float formats need FBOs. If FBOs are used this function isn't called */
if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
return FALSE;
if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
lockable = TRUE;
......@@ -4176,8 +4178,8 @@ HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id);
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
if ((rt_format->flags & WINED3DFMT_FLAG_RENDERTARGET)
&& (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
if ((rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET)
&& (ds_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
{
TRACE("Formats match.\n");
return WINED3D_OK;
......@@ -4268,7 +4270,8 @@ static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
/* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
if (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) return TRUE;
if (ds_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
return TRUE;
}
else
{
......@@ -4292,7 +4295,8 @@ static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
const struct wined3d_format *adapter_format, const struct wined3d_format *check_format)
{
/* Filter out non-RT formats */
if (!(check_format->flags & WINED3DFMT_FLAG_RENDERTARGET)) return FALSE;
if (!(check_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET))
return FALSE;
if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
{
BYTE AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
......@@ -4371,7 +4375,7 @@ static BOOL CheckSurfaceCapability(const struct wined3d_adapter *adapter,
/* All formats that are supported for textures are supported for surfaces
* as well. */
if (check_format->flags & WINED3DFMT_FLAG_TEXTURE)
if (check_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_TEXTURE)
return TRUE;
/* All depth stencil formats are supported on surfaces */
if (CheckDepthStencilCapability(adapter, adapter_format, check_format)) return TRUE;
......@@ -4454,7 +4458,8 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
break;
case WINED3D_RTYPE_TEXTURE:
if ((usage & WINED3DUSAGE_DEPTHSTENCIL) && (format->flags & WINED3DFMT_FLAG_SHADOW)
if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
&& (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
&& !gl_info->supported[ARB_SHADOW])
{
TRACE("[FAILED] - No shadow sampler support.\n");
......@@ -4542,10 +4547,10 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
format_flags |= WINED3DFMT_FLAG_BUMPMAP;
if ((format->flags & format_flags) != format_flags)
if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & format_flags) != format_flags)
{
TRACE("Requested format flags %#x, but format %s only has %#x.\n",
format_flags, debug_d3dformat(check_format_id), format->flags);
format_flags, debug_d3dformat(check_format_id), format->flags[WINED3D_GL_RES_TYPE_TEX_2D]);
return WINED3DERR_NOTAVAILABLE;
}
......
......@@ -72,7 +72,7 @@ static void resource_check_usage(DWORD usage)
}
HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
enum wined3d_resource_type type, const struct wined3d_format *format,
enum wined3d_resource_type type, enum wined3d_gl_resource_type gl_type, const struct wined3d_format *format,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
DWORD usage, enum wined3d_pool pool, UINT width, UINT height, UINT depth, UINT size,
void *parent, const struct wined3d_parent_ops *parent_ops,
......@@ -85,8 +85,9 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource->ref = 1;
resource->device = device;
resource->type = type;
resource->gl_type = gl_type;
resource->format = format;
resource->format_flags = format->flags;
resource->format_flags = format->flags[gl_type];
resource->multisample_type = multisample_type;
resource->multisample_quality = multisample_quality;
resource->usage = usage;
......
......@@ -989,16 +989,18 @@ static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum wined
switch (blit_op)
{
case WINED3D_BLIT_OP_COLOR_BLIT:
if (!((src_format->flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (src_usage & WINED3DUSAGE_RENDERTARGET)))
if (!((src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FBO_ATTACHABLE)
|| (src_usage & WINED3DUSAGE_RENDERTARGET)))
return FALSE;
if (!((dst_format->flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (dst_usage & WINED3DUSAGE_RENDERTARGET)))
if (!((dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FBO_ATTACHABLE)
|| (dst_usage & WINED3DUSAGE_RENDERTARGET)))
return FALSE;
break;
case WINED3D_BLIT_OP_DEPTH_BLIT:
if (!(src_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
if (!(src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
return FALSE;
if (!(dst_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
if (!(dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
return FALSE;
break;
......@@ -1430,7 +1432,7 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
surface->container->flags |= WINED3D_TEXTURE_PIN_SYSMEM;
}
if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_HEIGHT_SCALE)
{
update_h *= format->height_scale.numerator;
update_h /= format->height_scale.denominator;
......@@ -1442,7 +1444,7 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
checkGLcall("glBindBuffer");
}
if (format->flags & WINED3DFMT_FLAG_COMPRESSED)
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
{
UINT row_length = wined3d_format_calculate_size(format, 1, update_w, 1, 1);
UINT row_count = (update_h + format->block_height - 1) / format->block_height;
......@@ -4316,7 +4318,8 @@ static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info,
case WINED3D_BLIT_OP_COLOR_FILL:
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
if (!((dst_format->flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (dst_usage & WINED3DUSAGE_RENDERTARGET)))
if (!((dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FBO_ATTACHABLE)
|| (dst_usage & WINED3DUSAGE_RENDERTARGET)))
return FALSE;
}
else if (!(dst_usage & WINED3DUSAGE_RENDERTARGET))
......@@ -5457,9 +5460,9 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
else
surface->surface_ops = &surface_ops;
if (FAILED(hr = resource_init(&surface->resource, device, WINED3D_RTYPE_SURFACE, format,
desc->multisample_type, multisample_quality, desc->usage, desc->pool, desc->width, desc->height, 1,
resource_size, NULL, &wined3d_null_parent_ops, &surface_resource_ops)))
if (FAILED(hr = resource_init(&surface->resource, device, WINED3D_RTYPE_SURFACE, container->resource.gl_type,
format, desc->multisample_type, multisample_quality, desc->usage, desc->pool, desc->width, desc->height,
1, resource_size, NULL, &wined3d_null_parent_ops, &surface_resource_ops)))
{
WARN("Failed to initialize resource, returning %#x.\n", hr);
return hr;
......
......@@ -29,8 +29,8 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD surface_flags,
struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops)
enum wined3d_gl_resource_type gl_type, struct wined3d_device *device, void *parent,
const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops)
{
const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info, desc->format);
HRESULT hr;
......@@ -43,7 +43,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
debug_d3dusage(desc->usage), debug_d3dpool(desc->pool), desc->width, desc->height, desc->depth,
surface_flags, device, parent, parent_ops, resource_ops);
if ((format->flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BLOCKS_NO_VERIFY)) == WINED3DFMT_FLAG_BLOCKS)
if ((format->flags[gl_type] & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BLOCKS_NO_VERIFY))
== WINED3DFMT_FLAG_BLOCKS)
{
UINT width_mask = format->block_width - 1;
UINT height_mask = format->block_height - 1;
......@@ -51,15 +52,17 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
return WINED3DERR_INVALIDCALL;
}
if (FAILED(hr = resource_init(&texture->resource, device, desc->resource_type, format,
if (FAILED(hr = resource_init(&texture->resource, device, desc->resource_type, gl_type, format,
desc->multisample_type, desc->multisample_quality, desc->usage, desc->pool,
desc->width, desc->height, desc->depth, 0, parent, parent_ops, resource_ops)))
{
static unsigned int once;
/* DXTn 3D textures are not supported. Do not write the ERR for them. */
if ((desc->format == WINED3DFMT_DXT1 || desc->format == WINED3DFMT_DXT2 || desc->format == WINED3DFMT_DXT3
|| desc->format == WINED3DFMT_DXT4 || desc->format == WINED3DFMT_DXT5)
&& !(format->flags & WINED3DFMT_FLAG_TEXTURE) && !once++)
&& !(format->flags[gl_type] & WINED3DFMT_FLAG_TEXTURE) && gl_type != WINED3D_GL_RES_TYPE_TEX_3D
&& !once++)
ERR_(winediag)("The application tried to create a DXTn texture, but the driver does not support them.\n");
WARN("Failed to initialize resource, returning %#x\n", hr);
......@@ -1020,7 +1023,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi
}
if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 6, levels, desc,
surface_flags, device, parent, parent_ops, &texture_resource_ops)))
surface_flags, WINED3D_GL_RES_TYPE_TEX_CUBE, device, parent, parent_ops, &texture_resource_ops)))
{
WARN("Failed to initialize texture, returning %#x\n", hr);
return hr;
......@@ -1138,7 +1141,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
}
if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 1, levels, desc,
surface_flags, device, parent, parent_ops, &texture_resource_ops)))
surface_flags, WINED3D_GL_RES_TYPE_TEX_2D, device, parent, parent_ops, &texture_resource_ops)))
{
WARN("Failed to initialize texture, returning %#x.\n", hr);
return hr;
......@@ -1377,7 +1380,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
}
if (FAILED(hr = wined3d_texture_init(texture, &texture3d_ops, 1, levels, desc,
0, device, parent, parent_ops, &texture_resource_ops)))
0, WINED3D_GL_RES_TYPE_TEX_3D, device, parent, parent_ops, &texture_resource_ops)))
{
WARN("Failed to initialize texture, returning %#x.\n", hr);
return hr;
......
......@@ -101,7 +101,7 @@ static void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *vie
view->parent_ops = parent_ops;
view->format = wined3d_get_format(gl_info, desc->format_id);
view->format_flags = view->format->flags;
view->format_flags = view->format->flags[resource->gl_type];
if (resource->type == WINED3D_RTYPE_BUFFER)
{
view->sub_resource_idx = 0;
......
......@@ -764,8 +764,8 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture
size = wined3d_format_calculate_size(format, device->surface_alignment, desc->width, desc->height, desc->depth);
if (FAILED(hr = resource_init(&volume->resource, device, WINED3D_RTYPE_VOLUME, format,
WINED3D_MULTISAMPLE_NONE, 0, desc->usage, desc->pool, desc->width, desc->height, desc->depth,
if (FAILED(hr = resource_init(&volume->resource, device, WINED3D_RTYPE_VOLUME, container->resource.gl_type,
format, WINED3D_MULTISAMPLE_NONE, 0, desc->usage, desc->pool, desc->width, desc->height, desc->depth,
size, NULL, &wined3d_null_parent_ops, &volume_resource_ops)))
{
WARN("Failed to initialize resource, returning %#x.\n", hr);
......
......@@ -778,7 +778,8 @@ enum wined3d_gl_resource_type
WINED3D_GL_RES_TYPE_TEX_3D = 2,
WINED3D_GL_RES_TYPE_TEX_CUBE = 3,
WINED3D_GL_RES_TYPE_TEX_RECT = 4,
WINED3D_GL_RES_TYPE_COUNT = 5,
WINED3D_GL_RES_TYPE_BUFFER = 5,
WINED3D_GL_RES_TYPE_COUNT = 6,
};
enum vertexprocessing_mode {
......@@ -2105,6 +2106,7 @@ struct wined3d_resource
LONG map_count;
struct wined3d_device *device;
enum wined3d_resource_type type;
enum wined3d_gl_resource_type gl_type;
const struct wined3d_format *format;
unsigned int format_flags;
enum wined3d_multisample_type multisample_type;
......@@ -2139,7 +2141,7 @@ static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource)
void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
enum wined3d_resource_type type, const struct wined3d_format *format,
enum wined3d_resource_type type, enum wined3d_gl_resource_type gl_type, const struct wined3d_format *format,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
DWORD usage, enum wined3d_pool pool, UINT width, UINT height, UINT depth, UINT size,
void *parent, const struct wined3d_parent_ops *parent_ops,
......@@ -3170,7 +3172,7 @@ struct wined3d_format
GLint glFormat;
GLint glType;
UINT conv_byte_count;
unsigned int flags;
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment