user_assert(!(Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) ||
Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
user_assert(!(Usage & D3DUSAGE_DYNAMIC) ||
- Pool != D3DPOOL_MANAGED, D3DERR_INVALIDCALL);
+ !(Pool == D3DPOOL_MANAGED ||
+ Pool == D3DPOOL_SCRATCH), D3DERR_INVALIDCALL);
hr = NineResource9_ctor(&This->base, pParams, initResource, alloc, Type, Pool, Usage);
if (FAILED(hr))
util_format_has_depth(util_format_description(This->base.info.format));
list_inithead(&This->list);
+ list_inithead(&This->list2);
+ if (Pool == D3DPOOL_MANAGED)
+ list_add(&This->list2, &This->base.base.device->managed_textures);
return D3D_OK;
}
pipe_sampler_view_reference(&This->view[1], NULL);
if (This->list.prev != NULL && This->list.next != NULL)
- list_del(&This->list),
+ list_del(&This->list);
+ if (This->list2.prev != NULL && This->list2.next != NULL)
+ list_del(&This->list2);
NineResource9_dtor(&This->base);
}
-DWORD WINAPI
+DWORD NINE_WINAPI
NineBaseTexture9_SetLOD( struct NineBaseTexture9 *This,
DWORD LODNew )
{
return old;
}
-DWORD WINAPI
+DWORD NINE_WINAPI
NineBaseTexture9_GetLOD( struct NineBaseTexture9 *This )
{
DBG("This=%p\n", This);
return This->managed.lod;
}
-DWORD WINAPI
+DWORD NINE_WINAPI
NineBaseTexture9_GetLevelCount( struct NineBaseTexture9 *This )
{
DBG("This=%p\n", This);
return This->base.info.last_level + 1;
}
-HRESULT WINAPI
+HRESULT NINE_WINAPI
NineBaseTexture9_SetAutoGenFilterType( struct NineBaseTexture9 *This,
D3DTEXTUREFILTERTYPE FilterType )
{
user_assert(FilterType != D3DTEXF_NONE, D3DERR_INVALIDCALL);
This->mipfilter = FilterType;
+ This->dirty_mip = TRUE;
+ NineBaseTexture9_GenerateMipSubLevels(This);
return D3D_OK;
}
-D3DTEXTUREFILTERTYPE WINAPI
+D3DTEXTUREFILTERTYPE NINE_WINAPI
NineBaseTexture9_GetAutoGenFilterType( struct NineBaseTexture9 *This )
{
DBG("This=%p\n", This);
if (tex->dirty_box.width) {
for (l = min_level_dirty; l <= last_level; ++l) {
- u_box_minify_2d(&box, &tex->dirty_box, l);
+ u_box_minify_3d(&box, &tex->dirty_box, l);
NineVolume9_UploadSelf(tex->volumes[l], &box);
}
memset(&tex->dirty_box, 0, sizeof(tex->dirty_box));
return D3D_OK;
}
-void WINAPI
+void NINE_WINAPI
NineBaseTexture9_GenerateMipSubLevels( struct NineBaseTexture9 *This )
{
- struct pipe_resource *resource = This->base.resource;
-
+ struct pipe_resource *resource;
unsigned base_level = 0;
unsigned last_level = This->base.info.last_level - This->managed.lod;
unsigned first_layer = 0;
last_layer = util_max_layer(This->view[0]->texture, base_level);
+ resource = This->base.resource;
+
util_gen_mipmap(This->pipe, resource,
resource->format, base_level, last_level,
first_layer, last_layer, filter);
return D3D_OK;
}
-#define SWIZZLE_TO_REPLACE(s) (s == UTIL_FORMAT_SWIZZLE_0 || \
- s == UTIL_FORMAT_SWIZZLE_1 || \
- s == UTIL_FORMAT_SWIZZLE_NONE)
+#define SWIZZLE_TO_REPLACE(s) (s == PIPE_SWIZZLE_0 || \
+ s == PIPE_SWIZZLE_1 || \
+ s == PIPE_SWIZZLE_NONE)
HRESULT
NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
pipe_sampler_view_reference(&This->view[sRGB], NULL);
- swizzle[0] = PIPE_SWIZZLE_RED;
- swizzle[1] = PIPE_SWIZZLE_GREEN;
- swizzle[2] = PIPE_SWIZZLE_BLUE;
- swizzle[3] = PIPE_SWIZZLE_ALPHA;
+ swizzle[0] = PIPE_SWIZZLE_X;
+ swizzle[1] = PIPE_SWIZZLE_Y;
+ swizzle[2] = PIPE_SWIZZLE_Z;
+ swizzle[3] = PIPE_SWIZZLE_W;
desc = util_format_description(resource->format);
if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
/* msdn doc is incomplete here and wrong.
* all channel */
if (This->format == D3DFMT_DF16 ||
This->format == D3DFMT_DF24) {
- swizzle[1] = PIPE_SWIZZLE_ZERO;
- swizzle[2] = PIPE_SWIZZLE_ZERO;
- swizzle[3] = PIPE_SWIZZLE_ONE;
+ swizzle[1] = PIPE_SWIZZLE_0;
+ swizzle[2] = PIPE_SWIZZLE_0;
+ swizzle[3] = PIPE_SWIZZLE_1;
} else {
- swizzle[1] = PIPE_SWIZZLE_RED;
- swizzle[2] = PIPE_SWIZZLE_RED;
- swizzle[3] = PIPE_SWIZZLE_RED;
+ swizzle[1] = PIPE_SWIZZLE_X;
+ swizzle[2] = PIPE_SWIZZLE_X;
+ swizzle[3] = PIPE_SWIZZLE_X;
}
} else if (resource->format == PIPE_FORMAT_RGTC2_UNORM) {
- swizzle[0] = PIPE_SWIZZLE_GREEN;
- swizzle[1] = PIPE_SWIZZLE_RED;
- swizzle[2] = PIPE_SWIZZLE_ONE;
- swizzle[3] = PIPE_SWIZZLE_ONE;
+ swizzle[0] = PIPE_SWIZZLE_Y;
+ swizzle[1] = PIPE_SWIZZLE_X;
+ swizzle[2] = PIPE_SWIZZLE_1;
+ swizzle[3] = PIPE_SWIZZLE_1;
} else if (resource->format != PIPE_FORMAT_A8_UNORM &&
resource->format != PIPE_FORMAT_RGTC1_UNORM) {
/* exceptions:
* should have 1.0 for non-defined values */
for (i = 0; i < 4; i++) {
if (SWIZZLE_TO_REPLACE(desc->swizzle[i]))
- swizzle[i] = PIPE_SWIZZLE_ONE;
+ swizzle[i] = PIPE_SWIZZLE_1;
}
}
return This->view ? D3D_OK : D3DERR_DRIVERINTERNALERROR;
}
-void WINAPI
+void NINE_WINAPI
NineBaseTexture9_PreLoad( struct NineBaseTexture9 *This )
{
DBG("This=%p\n", This);
NineBaseTexture9_UploadSelf(This);
}
+void
+NineBaseTexture9_UnLoad( struct NineBaseTexture9 *This )
+{
+ if (This->base.pool != D3DPOOL_MANAGED ||
+ This->managed.lod_resident == -1)
+ return;
+
+ pipe_resource_reference(&This->base.resource, NULL);
+ This->managed.lod_resident = -1;
+ This->managed.dirty = TRUE;
+
+ /* If the texture is bound, we have to re-upload it */
+ BASETEX_REGISTER_UPDATE(This);
+}
+
#ifdef DEBUG
void
NineBaseTexture9_Dump( struct NineBaseTexture9 *This )