2006-02-25 13:15:08 +01:00
|
|
|
/*
|
|
|
|
* Direct3D 8
|
|
|
|
*
|
|
|
|
* Copyright 2005 Oliver Stieber
|
2002-06-26 01:23:03 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-06-26 01:23:03 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-02-20 11:11:35 +01:00
|
|
|
#include "initguid.h"
|
2002-09-28 00:46:16 +02:00
|
|
|
#include "d3d8_private.h"
|
2006-02-25 13:15:08 +01:00
|
|
|
#include "wine/debug.h"
|
2002-09-28 00:46:16 +02:00
|
|
|
|
2006-02-25 13:15:08 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
2002-06-26 01:23:03 +02:00
|
|
|
|
2006-02-25 13:15:08 +01:00
|
|
|
HRESULT WINAPI D3D8GetSWInfo(void) {
|
2002-06-26 01:23:03 +02:00
|
|
|
FIXME("(void): stub\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-25 13:15:08 +01:00
|
|
|
void WINAPI DebugSetMute(void) {
|
2003-06-05 00:45:57 +02:00
|
|
|
/* nothing to do */
|
2002-06-26 01:23:03 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:36 +02:00
|
|
|
IDirect3D8 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version)
|
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *object;
|
2007-05-22 23:57:30 +02:00
|
|
|
|
2012-05-03 21:49:36 +02:00
|
|
|
TRACE("sdk_version %#x.\n", sdk_version);
|
2009-08-25 08:17:14 +02:00
|
|
|
|
2018-02-08 00:10:51 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2012-05-03 21:49:36 +02:00
|
|
|
return NULL;
|
2002-09-28 00:46:16 +02:00
|
|
|
|
2012-05-03 21:49:36 +02:00
|
|
|
if (!d3d8_init(object))
|
2008-06-24 11:07:43 +02:00
|
|
|
{
|
2012-05-03 21:49:36 +02:00
|
|
|
WARN("Failed to initialize d3d8.\n");
|
2018-02-08 00:10:51 +01:00
|
|
|
heap_free(object);
|
2012-05-03 21:49:36 +02:00
|
|
|
return NULL;
|
2008-06-24 11:07:43 +02:00
|
|
|
}
|
2012-05-03 21:49:36 +02:00
|
|
|
|
|
|
|
TRACE("Created d3d8 object %p.\n", object);
|
|
|
|
|
2011-01-23 21:49:42 +01:00
|
|
|
return &object->IDirect3D8_iface;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2019-02-07 23:39:37 +01:00
|
|
|
/* FIXME: We should probably use libvkd3d-shader for validation. */
|
|
|
|
HRESULT WINAPI ValidateVertexShader(const DWORD *vs_code, const DWORD *declaration,
|
|
|
|
const D3DCAPS8 *caps, BOOL return_error, char **errors)
|
2009-08-31 09:57:52 +02:00
|
|
|
{
|
2019-02-07 23:39:37 +01:00
|
|
|
const char *message = "";
|
|
|
|
SIZE_T message_size;
|
|
|
|
HRESULT hr = E_FAIL;
|
2010-02-19 15:37:23 +01:00
|
|
|
|
2019-02-07 23:39:37 +01:00
|
|
|
TRACE("vs_code %p, declaration %p, caps %p, return_error %#x, errors %p.\n",
|
|
|
|
vs_code, declaration, caps, return_error, errors);
|
2006-09-10 13:05:45 +02:00
|
|
|
|
2019-02-07 23:39:37 +01:00
|
|
|
if (!vs_code)
|
|
|
|
{
|
|
|
|
message = "Invalid code pointer.\n";
|
|
|
|
goto done;
|
|
|
|
}
|
2006-09-10 13:05:45 +02:00
|
|
|
|
2019-02-07 23:39:37 +01:00
|
|
|
switch (*vs_code)
|
|
|
|
{
|
|
|
|
case D3DVS_VERSION(1, 1):
|
|
|
|
case D3DVS_VERSION(1, 0):
|
2006-09-10 13:05:45 +02:00
|
|
|
break;
|
2019-02-07 23:39:37 +01:00
|
|
|
|
2006-09-10 13:05:45 +02:00
|
|
|
default:
|
2019-02-07 23:39:37 +01:00
|
|
|
message = "Unsupported shader version.\n";
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (caps && *vs_code > caps->VertexShaderVersion)
|
|
|
|
{
|
|
|
|
message = "Shader version not supported by caps.\n";
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (!return_error)
|
|
|
|
message = "";
|
|
|
|
message_size = strlen(message) + 1;
|
|
|
|
if (errors && (*errors = heap_alloc(message_size)))
|
|
|
|
memcpy(*errors, message, message_size);
|
2006-09-10 13:05:45 +02:00
|
|
|
|
2019-02-07 23:39:37 +01:00
|
|
|
return hr;
|
2006-02-25 13:15:08 +01:00
|
|
|
}
|
|
|
|
|
2019-03-04 19:30:06 +01:00
|
|
|
HRESULT WINAPI ValidatePixelShader(const DWORD *ps_code,
|
|
|
|
const D3DCAPS8 *caps, BOOL return_error, char **errors)
|
2006-02-25 13:15:08 +01:00
|
|
|
{
|
2019-03-04 19:30:06 +01:00
|
|
|
const char *message = "";
|
|
|
|
SIZE_T message_size;
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
|
|
|
|
TRACE("ps_code %p, caps %p, return_error %#x, errors %p.\n",
|
|
|
|
ps_code, caps, return_error, errors);
|
|
|
|
|
|
|
|
if (!ps_code)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
switch (*ps_code)
|
|
|
|
{
|
|
|
|
case D3DPS_VERSION(1, 4):
|
|
|
|
case D3DPS_VERSION(1, 3):
|
|
|
|
case D3DPS_VERSION(1, 2):
|
|
|
|
case D3DPS_VERSION(1, 1):
|
|
|
|
case D3DPS_VERSION(1, 0):
|
2006-09-18 20:16:48 +02:00
|
|
|
break;
|
2019-03-04 19:30:06 +01:00
|
|
|
|
2006-09-18 20:16:48 +02:00
|
|
|
default:
|
2019-03-04 19:30:06 +01:00
|
|
|
message = "Unsupported shader version.\n";
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (caps && *ps_code > caps->PixelShaderVersion)
|
|
|
|
{
|
|
|
|
message = "Shader version not supported by caps.\n";
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (!return_error)
|
|
|
|
message = "";
|
|
|
|
message_size = strlen(message) + 1;
|
|
|
|
if (errors && (*errors = heap_alloc(message_size)))
|
|
|
|
memcpy(*errors, message, message_size);
|
|
|
|
|
|
|
|
return hr;
|
2006-02-25 13:15:08 +01:00
|
|
|
}
|
2014-03-21 11:46:19 +01:00
|
|
|
|
|
|
|
void d3d8_resource_cleanup(struct d3d8_resource *resource)
|
|
|
|
{
|
2014-03-21 11:46:20 +01:00
|
|
|
wined3d_private_store_cleanup(&resource->private_store);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT d3d8_resource_free_private_data(struct d3d8_resource *resource, const GUID *guid)
|
|
|
|
{
|
|
|
|
struct wined3d_private_data *entry;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
entry = wined3d_private_store_get_private_data(&resource->private_store, guid);
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return D3DERR_NOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
wined3d_private_store_free_private_data(&resource->private_store, entry);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT d3d8_resource_get_private_data(struct d3d8_resource *resource, const GUID *guid,
|
|
|
|
void *data, DWORD *data_size)
|
|
|
|
{
|
|
|
|
const struct wined3d_private_data *stored_data;
|
|
|
|
DWORD size_in;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
stored_data = wined3d_private_store_get_private_data(&resource->private_store, guid);
|
|
|
|
if (!stored_data)
|
|
|
|
{
|
|
|
|
hr = D3DERR_NOTFOUND;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_in = *data_size;
|
|
|
|
*data_size = stored_data->size;
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
hr = D3D_OK;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (size_in < stored_data->size)
|
|
|
|
{
|
|
|
|
hr = D3DERR_MOREDATA;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stored_data->flags & WINED3DSPD_IUNKNOWN)
|
|
|
|
IUnknown_AddRef(stored_data->content.object);
|
|
|
|
memcpy(data, stored_data->content.data, stored_data->size);
|
|
|
|
hr = D3D_OK;
|
|
|
|
|
|
|
|
done:
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return hr;
|
2014-03-21 11:46:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void d3d8_resource_init(struct d3d8_resource *resource)
|
|
|
|
{
|
|
|
|
resource->refcount = 1;
|
2014-03-21 11:46:20 +01:00
|
|
|
wined3d_private_store_init(&resource->private_store);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT d3d8_resource_set_private_data(struct d3d8_resource *resource, const GUID *guid,
|
|
|
|
const void *data, DWORD data_size, DWORD flags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
hr = wined3d_private_store_set_private_data(&resource->private_store, guid, data, data_size, flags);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return hr;
|
2014-03-21 11:46:19 +01:00
|
|
|
}
|