[PATCH v2 4/9] wined3d: Stub creation of WINED3D_RTYPE_TEXTURE_1D textures.
Józef Kucia
joseph.kucia at gmail.com
Thu Jan 4 05:19:31 CST 2018
On Wed, Jan 3, 2018 at 4:18 PM, Sven Hesse <shesse at codeweavers.com> wrote:
> @@ -2036,6 +2071,123 @@ static const struct wined3d_resource_ops texture_resource_ops =
> texture_resource_sub_resource_unmap,
> };
>
> +static HRESULT texture1d_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)
> +{
> + 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_DYNAMIC && desc->pool == WINED3D_POOL_MANAGED)
> + FIXME("Trying to create a managed texture with dynamic usage.\n");
> +
> + if ((desc->width & (desc->width - 1)) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
> + {
> + WARN("Attempted to create a NPOT 1D texture (%u) without GL support.\n", desc->width);
> + return WINED3DERR_INVALIDCALL;
> + }
> +
> + if (desc->width > gl_info->limits.texture_size && (desc->usage & WINED3DUSAGE_TEXTURE))
> + {
> + WARN("Dimensions (%ux) exceed the maximum texture size.\n", desc->width);
> + return WINED3DERR_NOTAVAILABLE;
> + }
> +
> + /* Calculate levels for mip mapping. */
> + if (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP)
> + {
> + if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
> + {
> + WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
> + return WINED3DERR_INVALIDCALL;
> + }
> +
> + if (level_count != 1)
> + {
> + WARN("WINED3DUSAGE_AUTOGENMIPMAP is set, and level count != 1, returning D3DERR_INVALIDCALL.\n");
> + return WINED3DERR_INVALIDCALL;
> + }
> + }
> +
> + if (FAILED(hr = wined3d_texture_init(texture, &texture1d_ops, layer_count, level_count, desc,
> + flags, 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))
> + 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 surface 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);
> +
> + TRACE("Created surface level %u, layer %u @ %p.\n", i, j, surface);
> + }
> + }
> +
> + return WINED3D_OK;
> +}
> +
This duplicates quite a lot of code. Did you consider integrating 1D
textures with 2D textures more closely?
More information about the wine-devel
mailing list