HRESULT wined3d_volume_init(struct wined3d_volume *volume, struct wined3d_texture *container, const struct wined3d_resource_desc *desc, UINT level) { struct wined3d_device *device = container->resource.device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format); HRESULT hr; UINT size; 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, size, NULL, &wined3d_null_parent_ops, &volume_resource_ops))) { WARN("Failed to initialize resource, returning %#x.\n", hr); return hr; } if (container->resource.map_binding == WINED3D_LOCATION_BUFFER) wined3d_resource_free_sysmem(&volume->resource); volume->texture_level = level; container->sub_resources[level].locations = WINED3D_LOCATION_DISCARDED; volume->container = container; return WINED3D_OK; }
static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device *device, UINT width, UINT height, UINT depth, UINT level, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, void *parent, const struct wined3d_parent_ops *parent_ops) { const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_format *format = wined3d_get_format(gl_info, format_id); HRESULT hr; UINT size; if (!gl_info->supported[EXT_TEXTURE3D]) { WARN("Volume cannot be created - no volume texture support.\n"); return WINED3DERR_INVALIDCALL; } /* TODO: Write tests for other resources and move this check * to resource_init, if applicable. */ if (usage & WINED3DUSAGE_DYNAMIC && (pool == WINED3D_POOL_MANAGED || pool == WINED3D_POOL_SCRATCH)) { WARN("Attempted to create a DYNAMIC texture in pool %u.\n", pool); return WINED3DERR_INVALIDCALL; } size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, depth); hr = resource_init(&volume->resource, device, WINED3D_RTYPE_VOLUME, format, WINED3D_MULTISAMPLE_NONE, 0, usage, pool, width, height, depth, size, parent, parent_ops, &volume_resource_ops); if (FAILED(hr)) { WARN("Failed to initialize resource, returning %#x.\n", hr); return hr; } volume->texture_level = level; volume->locations = WINED3D_LOCATION_DISCARDED; if (pool == WINED3D_POOL_DEFAULT && usage & WINED3DUSAGE_DYNAMIC && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) { wined3d_resource_free_sysmem(volume->resource.heap_memory); volume->resource.heap_memory = NULL; volume->resource.allocatedMemory = NULL; volume->flags |= WINED3D_VFLAG_PBO; } return WINED3D_OK; }
static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture *container, const struct wined3d_resource_desc *desc, UINT level) { struct wined3d_device *device = container->resource.device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format); HRESULT hr; UINT size; if (!gl_info->supported[EXT_TEXTURE3D]) { WARN("Volume cannot be created - no volume texture support.\n"); return WINED3DERR_INVALIDCALL; } /* TODO: Write tests for other resources and move this check * to resource_init, if applicable. */ if (desc->usage & WINED3DUSAGE_DYNAMIC && (desc->pool == WINED3D_POOL_MANAGED || desc->pool == WINED3D_POOL_SCRATCH)) { WARN("Attempted to create a DYNAMIC texture in pool %s.\n", debug_d3dpool(desc->pool)); return WINED3DERR_INVALIDCALL; } 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, size, NULL, &wined3d_null_parent_ops, &volume_resource_ops))) { WARN("Failed to initialize resource, returning %#x.\n", hr); return hr; } volume->texture_level = level; volume->locations = WINED3D_LOCATION_DISCARDED; if (desc->pool == WINED3D_POOL_DEFAULT && desc->usage & WINED3DUSAGE_DYNAMIC && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] && !format->convert) { wined3d_resource_free_sysmem(&volume->resource); volume->flags |= WINED3D_VFLAG_PBO; } volume->container = container; return WINED3D_OK; }