#endif
#include "util/u_format.h"
-#include "util/u_gen_mipmap.h"
#define DBG_CHANNEL DBG_BASETEXTURE
return hr;
This->format = format;
- This->pipe = pParams->device->pipe;
This->mipfilter = (Usage & D3DUSAGE_AUTOGENMIPMAP) ?
D3DTEXF_LINEAR : D3DTEXF_NONE;
This->managed.lod = 0;
pipe_sampler_view_reference(&This->view[0], NULL);
pipe_sampler_view_reference(&This->view[1], NULL);
- if (This->bind_count) {
- /* mark state dirty */
- struct nine_state *state = &This->base.base.device->state;
- unsigned s;
- for (s = 0; s < NINE_MAX_SAMPLERS; ++s)
- if (state->texture[s] == This)
- state->changed.texture |= 1 << s;
- if (state->changed.texture)
- state->changed.group |= NINE_STATE_TEXTURE;
- }
-
/* Allocate a new resource */
hr = NineBaseTexture9_CreatePipeResource(This, This->managed.lod_resident != -1);
if (FAILED(hr))
if (This->base.usage & D3DUSAGE_AUTOGENMIPMAP)
This->dirty_mip = TRUE;
+ /* Set again the textures currently bound to update the texture data */
+ if (This->bind_count) {
+ struct nine_state *state = &This->base.base.device->state;
+ unsigned s;
+ for (s = 0; s < NINE_MAX_SAMPLERS; ++s)
+ /* Dirty tracking is done in device9 state, not nine_context. */
+ if (state->texture[s] == This)
+ nine_context_set_texture(This->base.base.device, s, This);
+ }
+
DBG("DONE, generate mip maps = %i\n", This->dirty_mip);
return D3D_OK;
}
void NINE_WINAPI
NineBaseTexture9_GenerateMipSubLevels( struct NineBaseTexture9 *This )
{
- 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);
+ nine_context_gen_mipmap(This->base.base.device, (struct NineUnknown *)This,
+ This->base.resource,
+ base_level, last_level,
+ first_layer, last_layer, filter);
This->dirty_mip = FALSE;
}
NineBaseTexture9_CreatePipeResource( struct NineBaseTexture9 *This,
BOOL CopyData )
{
- struct pipe_context *pipe = This->pipe;
+ struct pipe_context *pipe;
struct pipe_screen *screen = This->base.info.screen;
struct pipe_resource templ;
unsigned l, m;
box.height = u_minify(templ.height0, l);
box.depth = u_minify(templ.depth0, l);
+ pipe = nine_context_get_pipe_acquire(This->base.base.device);
+
for (; l <= templ.last_level; ++l, ++m) {
pipe->resource_copy_region(pipe,
res, l, 0, 0, 0,
box.height = u_minify(box.height, 1);
box.depth = u_minify(box.depth, 1);
}
+
+ nine_context_get_pipe_release(This->base.base.device);
}
pipe_resource_reference(&old, NULL);
const int sRGB )
{
const struct util_format_description *desc;
- struct pipe_context *pipe = This->pipe;
- struct pipe_screen *screen = pipe->screen;
+ struct pipe_context *pipe;
+ struct pipe_screen *screen = NineDevice9_GetScreen(This->base.base.device);
struct pipe_resource *resource = This->base.resource;
struct pipe_sampler_view templ;
enum pipe_format srgb_format;
srgb_format = util_format_srgb(resource->format);
if (sRGB && srgb_format != PIPE_FORMAT_NONE &&
screen->is_format_supported(screen, srgb_format,
- resource->target, 0, resource->bind))
+ resource->target, 0, 0, resource->bind))
templ.format = srgb_format;
else
templ.format = resource->format;
templ.swizzle_a = swizzle[3];
templ.target = resource->target;
+ pipe = nine_context_get_pipe_acquire(This->base.base.device);
This->view[sRGB] = pipe->create_sampler_view(pipe, resource, &templ);
+ nine_context_get_pipe_release(This->base.base.device);
DBG("sampler view = %p(resource = %p)\n", This->view[sRGB], resource);