ddraw: Make the DDSURFACEDESC2 parameter to ddraw_surface_create_texture() const.
This commit is contained in:
parent
2c109d2df1
commit
028960d9d0
|
@ -2808,21 +2808,13 @@ static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWO
|
||||||
* DDERR_* if an error occurs
|
* DDERR_* if an error occurs
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
|
static HRESULT CreateSurface(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
|
||||||
struct ddraw_surface **surface, IUnknown *UnkOuter, UINT version)
|
struct ddraw_surface **surface, IUnknown *UnkOuter, UINT version)
|
||||||
{
|
{
|
||||||
struct ddraw_surface *object = NULL;
|
struct ddraw_surface *object = NULL;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
DDSURFACEDESC2 desc2;
|
|
||||||
|
|
||||||
TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p.\n", ddraw, DDSD, surface, UnkOuter);
|
TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p.\n", ddraw, surface_desc, surface, UnkOuter);
|
||||||
|
|
||||||
/* Some checks before we start */
|
|
||||||
if (TRACE_ON(ddraw))
|
|
||||||
{
|
|
||||||
TRACE(" (%p) Requesting surface desc :\n", ddraw);
|
|
||||||
DDRAW_dump_surface_desc(DDSD);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UnkOuter != NULL)
|
if (UnkOuter != NULL)
|
||||||
{
|
{
|
||||||
|
@ -2836,10 +2828,7 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
|
||||||
return E_POINTER; /* unchecked */
|
return E_POINTER; /* unchecked */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modify some flags */
|
if (FAILED(hr = ddraw_surface_create_texture(ddraw, surface_desc, version, &object)))
|
||||||
copy_to_surfacedesc2(&desc2, DDSD);
|
|
||||||
|
|
||||||
if (FAILED(hr = ddraw_surface_create_texture(ddraw, &desc2, version, &object)))
|
|
||||||
{
|
{
|
||||||
WARN("Failed to create texture, hr %#x.\n", hr);
|
WARN("Failed to create texture, hr %#x.\n", hr);
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -2848,7 +2837,7 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
|
||||||
|
|
||||||
*surface = object;
|
*surface = object;
|
||||||
|
|
||||||
if (desc2.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
if (surface_desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
||||||
ddraw->primary = object;
|
ddraw->primary = object;
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
|
|
|
@ -193,7 +193,7 @@ struct ddraw_texture
|
||||||
struct ddraw_surface *root;
|
struct ddraw_surface *root;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, const DDSURFACEDESC2 *desc,
|
||||||
unsigned int version, struct ddraw_surface **surface) DECLSPEC_HIDDEN;
|
unsigned int version, struct ddraw_surface **surface) DECLSPEC_HIDDEN;
|
||||||
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
|
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
|
||||||
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
|
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
|
||||||
|
@ -611,7 +611,7 @@ struct member_info
|
||||||
#define SIZEOF_END_PADDING(type, last_field) \
|
#define SIZEOF_END_PADDING(type, last_field) \
|
||||||
(sizeof(type) - offsetof(type, last_field) - sizeof(((type *)0)->last_field))
|
(sizeof(type) - offsetof(type, last_field) - sizeof(((type *)0)->last_field))
|
||||||
|
|
||||||
static inline void copy_to_surfacedesc2(DDSURFACEDESC2 *to, DDSURFACEDESC2 *from)
|
static inline void copy_to_surfacedesc2(DDSURFACEDESC2 *to, const DDSURFACEDESC2 *from)
|
||||||
{
|
{
|
||||||
DWORD from_size = from->dwSize;
|
DWORD from_size = from->dwSize;
|
||||||
if (from_size == sizeof(DDSURFACEDESC))
|
if (from_size == sizeof(DDSURFACEDESC))
|
||||||
|
|
|
@ -5589,7 +5589,7 @@ static HRESULT CDECL ddraw_reset_enum_callback(struct wined3d_resource *resource
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
|
||||||
unsigned int version, struct ddraw_surface **surface)
|
unsigned int version, struct ddraw_surface **surface)
|
||||||
{
|
{
|
||||||
struct ddraw_surface *root, *mip, **attach;
|
struct ddraw_surface *root, *mip, **attach;
|
||||||
|
@ -5597,17 +5597,24 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
struct wined3d_texture *wined3d_texture;
|
struct wined3d_texture *wined3d_texture;
|
||||||
struct wined3d_resource *resource;
|
struct wined3d_resource *resource;
|
||||||
struct wined3d_display_mode mode;
|
struct wined3d_display_mode mode;
|
||||||
|
DDSURFACEDESC2 *desc, *mip_desc;
|
||||||
struct ddraw_texture *texture;
|
struct ddraw_texture *texture;
|
||||||
UINT layers, levels, i, j;
|
UINT layers, levels, i, j;
|
||||||
DDSURFACEDESC2 *mip_desc;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if (TRACE_ON(ddraw))
|
if (TRACE_ON(ddraw))
|
||||||
{
|
{
|
||||||
TRACE("Requesting surface desc:\n");
|
TRACE("Requesting surface desc:\n");
|
||||||
DDRAW_dump_surface_desc(desc);
|
DDRAW_dump_surface_desc(surface_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(texture = HeapAlloc(GetProcessHeap(), 0, sizeof(*texture))))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
texture->version = version;
|
||||||
|
copy_to_surfacedesc2(&texture->surface_desc, surface_desc);
|
||||||
|
desc = &texture->surface_desc;
|
||||||
|
|
||||||
/* Ensure DDSD_CAPS is always set. */
|
/* Ensure DDSD_CAPS is always set. */
|
||||||
desc->dwFlags |= DDSD_CAPS;
|
desc->dwFlags |= DDSD_CAPS;
|
||||||
|
|
||||||
|
@ -5621,6 +5628,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
&& !(ddraw->cooperative_level & DDSCL_EXCLUSIVE))
|
&& !(ddraw->cooperative_level & DDSCL_EXCLUSIVE))
|
||||||
{
|
{
|
||||||
WARN("Tried to create a flippable primary surface without DDSCL_EXCLUSIVE.\n");
|
WARN("Tried to create a flippable primary surface without DDSCL_EXCLUSIVE.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_NOEXCLUSIVEMODE;
|
return DDERR_NOEXCLUSIVEMODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5628,6 +5636,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
== (DDSCAPS_BACKBUFFER | DDSCAPS_PRIMARYSURFACE))
|
== (DDSCAPS_BACKBUFFER | DDSCAPS_PRIMARYSURFACE))
|
||||||
{
|
{
|
||||||
WARN("Tried to create a back buffer surface.\n");
|
WARN("Tried to create a back buffer surface.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDCAPS;
|
return DDERR_INVALIDCAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5636,6 +5645,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
== (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY))
|
== (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY))
|
||||||
{
|
{
|
||||||
WARN("Tried to create a surface in both system and video memory.\n");
|
WARN("Tried to create a surface in both system and video memory.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDCAPS;
|
return DDERR_INVALIDCAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5643,6 +5653,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
&& !(desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP))
|
&& !(desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP))
|
||||||
{
|
{
|
||||||
WARN("Cube map faces requested without cube map flag.\n");
|
WARN("Cube map faces requested without cube map flag.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDCAPS;
|
return DDERR_INVALIDCAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5650,6 +5661,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
&& !(desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES))
|
&& !(desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES))
|
||||||
{
|
{
|
||||||
WARN("Cube map without faces requested.\n");
|
WARN("Cube map without faces requested.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5662,12 +5674,14 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
if (!(desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
if (!(desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
||||||
{
|
{
|
||||||
WARN("DDSCAPS2_TEXTUREMANAGE used without DDSCAPS_TEXTURE, returning DDERR_INVALIDCAPS.\n");
|
WARN("DDSCAPS2_TEXTUREMANAGE used without DDSCAPS_TEXTURE, returning DDERR_INVALIDCAPS.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDCAPS;
|
return DDERR_INVALIDCAPS;
|
||||||
}
|
}
|
||||||
if (desc->ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY))
|
if (desc->ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY))
|
||||||
{
|
{
|
||||||
WARN("DDSCAPS2_TEXTUREMANAGE used width DDSCAPS_VIDEOMEMORY "
|
WARN("DDSCAPS2_TEXTUREMANAGE used width DDSCAPS_VIDEOMEMORY "
|
||||||
"or DDSCAPS_SYSTEMMEMORY, returning DDERR_INVALIDCAPS.\n");
|
"or DDSCAPS_SYSTEMMEMORY, returning DDERR_INVALIDCAPS.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDCAPS;
|
return DDERR_INVALIDCAPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5675,6 +5689,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
if (FAILED(hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL)))
|
if (FAILED(hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL)))
|
||||||
{
|
{
|
||||||
ERR("Failed to get display mode, hr %#x.\n", hr);
|
ERR("Failed to get display mode, hr %#x.\n", hr);
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5690,6 +5705,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
if (wined3d_desc.format == WINED3DFMT_UNKNOWN)
|
if (wined3d_desc.format == WINED3DFMT_UNKNOWN)
|
||||||
{
|
{
|
||||||
WARN("Unsupported / unknown pixelformat.\n");
|
WARN("Unsupported / unknown pixelformat.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDPIXELFORMAT;
|
return DDERR_INVALIDPIXELFORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5699,6 +5715,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
if (!(desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
if (!(desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
||||||
{
|
{
|
||||||
WARN("No width / height specified.\n");
|
WARN("No width / height specified.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5708,7 +5725,10 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!desc->dwWidth || !desc->dwHeight)
|
if (!desc->dwWidth || !desc->dwHeight)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
|
}
|
||||||
|
|
||||||
if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
||||||
{
|
{
|
||||||
|
@ -5728,6 +5748,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
&swapchain_desc, NULL, ddraw_reset_enum_callback, TRUE)))
|
&swapchain_desc, NULL, ddraw_reset_enum_callback, TRUE)))
|
||||||
{
|
{
|
||||||
ERR("Failed to reset device.\n");
|
ERR("Failed to reset device.\n");
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5757,7 +5778,10 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
{
|
{
|
||||||
/* Mipmap count is given, should not be 0. */
|
/* Mipmap count is given, should not be 0. */
|
||||||
if (!desc->u2.dwMipMapCount)
|
if (!desc->u2.dwMipMapCount)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, texture);
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5853,12 +5877,6 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
|
||||||
if (desc->ddsCaps.dwCaps & DDSCAPS_OWNDC)
|
if (desc->ddsCaps.dwCaps & DDSCAPS_OWNDC)
|
||||||
wined3d_desc.usage |= WINED3DUSAGE_OWNDC;
|
wined3d_desc.usage |= WINED3DUSAGE_OWNDC;
|
||||||
|
|
||||||
if (!(texture = HeapAlloc(GetProcessHeap(), 0, sizeof(*texture))))
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
|
|
||||||
texture->version = version;
|
|
||||||
copy_to_surfacedesc2(&texture->surface_desc, desc);
|
|
||||||
|
|
||||||
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
||||||
{
|
{
|
||||||
wined3d_desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE;
|
wined3d_desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE;
|
||||||
|
|
Loading…
Reference in New Issue