2018-03-16 16:29:06 -07:00
|
|
|
From 011a76f062774cfa6a4f6081d3ab773ffbb9f93f Mon Sep 17 00:00:00 2001
|
2016-08-31 08:42:50 -07:00
|
|
|
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
|
|
|
Date: Thu, 25 Aug 2016 19:24:47 +0200
|
2018-02-21 21:23:14 -08:00
|
|
|
Subject: [PATCH] wined3d: Create dummy 1d textures and surfaces.
|
2016-08-31 08:42:50 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
dlls/wined3d/resource.c | 1 +
|
2018-03-15 17:28:58 -07:00
|
|
|
dlls/wined3d/texture.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
2 files changed, 168 insertions(+)
|
2016-08-31 08:42:50 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
|
2018-03-16 16:29:06 -07:00
|
|
|
index 97f7aec4e12..f3402179acf 100644
|
2016-08-31 08:42:50 -07:00
|
|
|
--- a/dlls/wined3d/resource.c
|
|
|
|
+++ b/dlls/wined3d/resource.c
|
2018-02-21 21:23:14 -08:00
|
|
|
@@ -75,6 +75,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
|
2016-08-31 08:42:50 -07:00
|
|
|
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},
|
|
|
|
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
|
2018-03-16 16:29:06 -07:00
|
|
|
index 9fc0d22ed41..73874725ca6 100644
|
2016-08-31 08:42:50 -07:00
|
|
|
--- a/dlls/wined3d/texture.c
|
|
|
|
+++ b/dlls/wined3d/texture.c
|
2018-03-16 16:29:06 -07:00
|
|
|
@@ -1715,6 +1715,40 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
|
2016-12-06 12:52:20 -08:00
|
|
|
context, box, data, row_pitch, slice_pitch);
|
2016-08-31 08:42:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+/* 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,
|
2016-12-06 12:52:20 -08:00
|
|
|
+ const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data,
|
2016-08-31 08:42:50 -07:00
|
|
|
+ unsigned int row_pitch, unsigned int slice_pitch)
|
|
|
|
+{
|
2016-12-06 12:52:20 -08:00
|
|
|
+ FIXME("texture %p, sub_resource_idx %u, context %p, box %p, data {%#x:%p}, row_pitch %#x, slice_pitch %#x: stub.\n",
|
|
|
|
+ texture, sub_resource_idx, context, box, data->buffer_object, data->addr, row_pitch, slice_pitch);
|
2016-08-31 08:42:50 -07:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* 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)
|
|
|
|
+{
|
|
|
|
+ FIXME("texture %p, sub_resource_idx %u, context %p, location %s: stub.\n",
|
|
|
|
+ texture, sub_resource_idx, context, wined3d_debug_location(location));
|
|
|
|
+
|
|
|
|
+ return FALSE;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void texture1d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
|
|
|
|
+{
|
|
|
|
+ FIXME("stub.\n");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static const struct wined3d_texture_ops texture1d_ops =
|
|
|
|
+{
|
|
|
|
+ texture1d_upload_data,
|
|
|
|
+ texture1d_load_location,
|
2018-03-15 17:28:58 -07:00
|
|
|
+ texture1d_prepare_texture
|
2016-08-31 08:42:50 -07:00
|
|
|
+};
|
|
|
|
+
|
|
|
|
static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
|
2016-12-06 12:52:20 -08:00
|
|
|
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)
|
2018-03-16 16:29:06 -07:00
|
|
|
@@ -2411,6 +2445,135 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
2016-08-31 08:42:50 -07:00
|
|
|
|
|
|
|
+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;
|
2018-03-15 17:28:58 -07:00
|
|
|
+ unsigned int sub_count, i;
|
2016-08-31 08:42:50 -07:00
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
2018-02-22 14:33:49 -08:00
|
|
|
+ if ((desc->usage & WINED3DUSAGE_DYNAMIC && wined3d_resource_access_is_managed(desc->access))
|
|
|
|
+ || (desc->usage & WINED3DUSAGE_SCRATCH))
|
2016-08-31 08:42:50 -07:00
|
|
|
+ {
|
2018-02-19 13:34:26 -08:00
|
|
|
+ WARN("Attempted to create a DYNAMIC texture in pool %s.\n", wined3d_debug_resource_access(desc->access));
|
2016-08-31 08:42:50 -07:00
|
|
|
+ return WINED3DERR_INVALIDCALL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] && !is_power_of_two(desc->width))
|
|
|
|
+ {
|
2018-02-19 12:16:57 -08:00
|
|
|
+ if (desc->usage & WINED3DUSAGE_SCRATCH)
|
2016-08-31 08:42:50 -07:00
|
|
|
+ {
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2018-02-17 19:36:07 -08:00
|
|
|
+ if (desc->usage & WINED3DUSAGE_QUERY_GENMIPMAP)
|
2016-08-31 08:42:50 -07:00
|
|
|
+ {
|
|
|
|
+ if (level_count != 1)
|
|
|
|
+ {
|
2018-02-19 12:56:22 -08:00
|
|
|
+ WARN("WINED3DUSAGE_QUERY_GENMIPMAP is set, and level count != 1, returning WINED3DERR_INVALIDCALL.\n");
|
2016-08-31 08:42:50 -07:00
|
|
|
+ return WINED3DERR_INVALIDCALL;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2018-03-16 16:29:06 -07:00
|
|
|
+ if (FAILED(hr = wined3d_texture_init(texture, desc, layer_count, level_count,
|
|
|
|
+ 0, device, parent, parent_ops, &texture1d_ops)))
|
2016-08-31 08:42:50 -07:00
|
|
|
+ {
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
2018-03-15 17:28:58 -07:00
|
|
|
+ sub_count = level_count * layer_count;
|
|
|
|
+ if (sub_count / layer_count != level_count)
|
2016-08-31 08:42:50 -07:00
|
|
|
+ {
|
|
|
|
+ wined3d_texture_cleanup_sync(texture);
|
|
|
|
+ return E_OUTOFMEMORY;
|
|
|
|
+ }
|
|
|
|
+
|
2018-03-15 17:28:58 -07:00
|
|
|
+ /* Generate all sub-resources. */
|
|
|
|
+ for (i = 0; i < sub_count; ++i)
|
2016-08-31 08:42:50 -07:00
|
|
|
+ {
|
2018-03-15 17:28:58 -07:00
|
|
|
+ struct wined3d_texture_sub_resource *sub_resource;
|
|
|
|
+
|
|
|
|
+ sub_resource = &texture->sub_resources[i];
|
|
|
|
+ sub_resource->locations = WINED3D_LOCATION_DISCARDED;
|
|
|
|
+ if (!(texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL))
|
|
|
|
+ {
|
|
|
|
+ wined3d_texture_validate_location(texture, i, WINED3D_LOCATION_SYSMEM);
|
|
|
|
+ wined3d_texture_invalidate_location(texture, i, ~WINED3D_LOCATION_SYSMEM);
|
|
|
|
+ }
|
|
|
|
+
|
2018-03-16 16:29:06 -07:00
|
|
|
+ if (FAILED(hr = device_parent->ops->texture_sub_resource_created(device_parent,
|
|
|
|
+ desc->resource_type, texture, i, &sub_resource->parent, &sub_resource->parent_ops)))
|
2016-08-31 08:42:50 -07:00
|
|
|
+ {
|
2018-03-15 17:28:58 -07:00
|
|
|
+ WARN("Failed to create sub-resource parent, hr %#x.\n", hr);
|
|
|
|
+ sub_resource->parent = NULL;
|
|
|
|
+ wined3d_texture_cleanup_sync(texture);
|
|
|
|
+ return hr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TRACE("parent %p, parent_ops %p.\n", sub_resource->parent, sub_resource->parent_ops);
|
2016-08-31 08:42:50 -07:00
|
|
|
+
|
2018-03-15 17:28:58 -07:00
|
|
|
+ TRACE("Created sub-resource %u (level %u, layer %u).\n",
|
|
|
|
+ i, i % texture->level_count, i / texture->level_count);
|
2016-08-31 08:42:50 -07:00
|
|
|
+
|
2018-03-15 17:28:58 -07:00
|
|
|
+ if ((desc->usage & WINED3DUSAGE_OWNDC) || (device->wined3d->flags & WINED3D_NO3D))
|
|
|
|
+ {
|
|
|
|
+ struct wined3d_texture_idx texture_idx = {texture, i};
|
2016-08-31 08:42:50 -07:00
|
|
|
+
|
2018-03-15 17:28:58 -07:00
|
|
|
+ wined3d_cs_init_object(device->cs, wined3d_texture_create_dc, &texture_idx);
|
|
|
|
+ device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
|
|
|
|
+ if (!texture->dc_info || !texture->dc_info[i].dc)
|
2016-08-31 08:42:50 -07:00
|
|
|
+ {
|
|
|
|
+ wined3d_texture_cleanup_sync(texture);
|
2018-03-15 17:28:58 -07:00
|
|
|
+ return WINED3DERR_INVALIDCALL;
|
2016-08-31 08:42:50 -07:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return WINED3D_OK;
|
|
|
|
+}
|
|
|
|
+
|
2018-03-16 16:29:06 -07:00
|
|
|
/* This call just uploads data, the caller is responsible for binding the
|
|
|
|
* correct texture. */
|
|
|
|
/* Context activation is done by the caller. */
|
|
|
|
@@ -2985,6 +3148,10 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
|
2016-08-31 08:42:50 -07:00
|
|
|
|
|
|
|
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:
|
2018-03-16 16:29:06 -07:00
|
|
|
hr = wined3d_texture_init(object, desc, layer_count, level_count,
|
|
|
|
flags, device, parent, parent_ops, &texture2d_ops);
|
2016-08-31 08:42:50 -07:00
|
|
|
--
|
2018-03-16 16:29:06 -07:00
|
|
|
2.16.2
|
2016-08-31 08:42:50 -07:00
|
|
|
|