Lines Matching refs:This
5 * copy of this software and associated documentation files (the "Software"),
11 * The above copyright notice and this permission notice (including the next
49 NineSurface9_CreatePipeSurfaces( struct NineSurface9 *This );
52 NineSurface9_ctor( struct NineSurface9 *This,
66 DBG("This=%p pDevice=%p pResource=%p Level=%u Layer=%u pDesc=%p\n",
67 This, pParams->device, pResource, Level, Layer, pDesc);
69 /* Mark this as a special surface held by another internal resource. */
71 This->base.base.device = pParams->device; /* Early fill this field in case of failure */
84 This->data = user_buffer;
98 /* TODO: this is (except width and height) duplicate from
101 This->base.info.screen = pParams->device->screen;
102 This->base.info.target = PIPE_TEXTURE_2D;
103 This->base.info.width0 = pDesc->Width;
104 This->base.info.height0 = pDesc->Height;
105 This->base.info.depth0 = 1;
106 This->base.info.last_level = 0;
107 This->base.info.array_size = 1;
108 This->base.info.nr_samples = multisample_type;
109 This->base.info.nr_storage_samples = multisample_type;
110 This->base.info.usage = PIPE_USAGE_DEFAULT;
111 This->base.info.bind = PIPE_BIND_SAMPLER_VIEW; /* StretchRect */
114 This->base.info.bind |= PIPE_BIND_RENDER_TARGET;
118 This->base.info.bind = d3d9_get_pipe_depth_format_bindings(pDesc->Format);
120 This->base.info.bind |= PIPE_BIND_SAMPLER_VIEW;
123 This->base.info.flags = 0;
124 This->base.info.format = d3d9_to_pipe_format_checked(This->base.info.screen,
126 This->base.info.target,
127 This->base.info.nr_samples,
128 This->base.info.bind,
132 if (This->base.info.format == PIPE_FORMAT_NONE && pDesc->Format != D3DFMT_NULL)
136 const unsigned w = util_format_get_blockwidth(This->base.info.format);
137 const unsigned h = util_format_get_blockheight(This->base.info.format);
144 This->format_internal = d3d9_to_pipe_format_checked(This->base.info.screen,
146 This->base.info.target,
147 This->base.info.nr_samples,
148 This->base.info.bind,
151 if (This->base.info.format != This->format_internal ||
157 This->data_internal = nine_allocate(pParams->device->allocator,
158 nine_format_get_level_alloc_size(This->format_internal,
162 if (!This->data_internal)
164 This->stride_internal = nine_format_get_stride(This->format_internal,
171 This->data = nine_allocate(pParams->device->allocator,
172 nine_format_get_level_alloc_size(This->base.info.format,
176 if (!This->data)
180 hr = NineResource9_ctor(&This->base, pParams, pResource,
187 This->transfer = NULL;
189 This->texture = TextureType;
190 This->level = Level;
191 This->level_actual = Level;
192 This->layer = Layer;
193 This->desc = *pDesc;
195 This->stride = nine_format_get_stride(This->base.info.format, pDesc->Width);
197 if (This->base.resource && (pDesc->Usage & D3DUSAGE_DYNAMIC))
198 This->base.resource->flags |= NINE_RESOURCE_FLAG_LOCKABLE;
200 if (This->base.resource && (pDesc->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)))
201 NineSurface9_CreatePipeSurfaces(This);
204 if (This->base.resource && (pDesc->Usage & D3DUSAGE_RENDERTARGET))
205 nine_context_clear_render_target(pParams->device, This, 0, 0, 0, pDesc->Width, pDesc->Height);
207 NineSurface9_Dump(This);
213 NineSurface9_dtor( struct NineSurface9 *This )
215 bool is_worker = nine_context_is_worker(This->base.base.device);
216 DBG("This=%p\n", This);
218 if (This->transfer) {
219 struct pipe_context *pipe = nine_context_get_pipe_multithread(This->base.base.device);
220 pipe->texture_unmap(pipe, This->transfer);
221 This->transfer = NULL;
227 if (p_atomic_read(&This->pending_uploads_counter))
228 nine_csmt_process(This->base.base.device);
230 pipe_surface_reference(&This->surface[0], NULL);
231 pipe_surface_reference(&This->surface[1], NULL);
233 if (!is_worker && This->lock_count && (This->data_internal || This->data)) {
235 nine_pointer_strongrelease(This->base.base.device->allocator,
236 This->data_internal ? This->data_internal : This->data);
240 if (This->data) {
242 nine_free_worker(This->base.base.device->allocator, This->data);
244 nine_free(This->base.base.device->allocator, This->data);
246 if (This->data_internal) {
248 nine_free_worker(This->base.base.device->allocator, This->data_internal);
250 nine_free(This->base.base.device->allocator, This->data_internal);
252 NineResource9_dtor(&This->base);
256 NineSurface9_CreatePipeSurfaces( struct NineSurface9 *This )
259 struct pipe_screen *screen = NineDevice9_GetScreen(This->base.base.device);
260 struct pipe_resource *resource = This->base.resource;
264 assert(This->desc.Pool == D3DPOOL_DEFAULT);
275 templ.u.tex.level = This->level;
276 templ.u.tex.first_layer = This->layer;
277 templ.u.tex.last_layer = This->layer;
279 pipe = nine_context_get_pipe_acquire(This->base.base.device);
281 This->surface[0] = pipe->create_surface(pipe, resource, &templ);
285 templ.u.tex.level = This->level;
286 templ.u.tex.first_layer = This->layer;
287 templ.u.tex.last_layer = This->layer;
289 This->surface[1] = pipe->create_surface(pipe, resource, &templ);
291 nine_context_get_pipe_release(This->base.base.device);
293 assert(This->surface[0]); /* TODO: Handle failure */
294 assert(This->surface[1]);
299 NineSurface9_Dump( struct NineSurface9 *This )
307 "Level=%u(%u), Layer=%u\n", This, This->base.resource, This->data,
308 nine_D3DPOOL_to_str(This->desc.Pool),
309 nine_D3DRTYPE_to_str(This->desc.Type),
310 nine_D3DUSAGE_to_str(This->desc.Usage),
311 This->desc.Width, This->desc.Height,
312 d3dformat_to_string(This->desc.Format), This->stride,
313 This->base.resource &&
314 (This->base.resource->flags & NINE_RESOURCE_FLAG_LOCKABLE),
315 This->level, This->level_actual, This->layer);
317 if (!This->base.base.container)
319 NineUnknown_QueryInterface(This->base.base.container, ref, (void **)&tex);
328 NineSurface9_GetContainer( struct NineSurface9 *This,
335 DBG("This=%p riid=%p id=%s ppContainer=%p\n",
336 This, riid, riid ? GUID_sprintf(guid_str, riid) : "", ppContainer);
343 hr = NineUnknown_QueryInterface(NineUnknown(This)->container ?
344 NineUnknown(This)->container : &NineUnknown(This)->device->base,
352 NineSurface9_MarkContainerDirty( struct NineSurface9 *This )
354 if (This->texture) {
356 NineBaseTexture9(This->base.base.container);
358 assert(This->texture == D3DRTYPE_TEXTURE ||
359 This->texture == D3DRTYPE_CUBETEXTURE);
360 if (This->base.pool == D3DPOOL_MANAGED)
363 if (This->base.usage & D3DUSAGE_AUTOGENMIPMAP)
371 NineSurface9_GetDesc( struct NineSurface9 *This,
375 DBG("This=%p pDesc=%p\n", This, pDesc);
376 *pDesc = This->desc;
382 NineSurface9_AddDirtyRect( struct NineSurface9 *This,
387 DBG("This=%p box=%p\n", This, box);
389 assert (This->base.pool != D3DPOOL_MANAGED ||
390 This->texture == D3DRTYPE_CUBETEXTURE ||
391 This->texture == D3DRTYPE_TEXTURE);
393 if (This->base.pool == D3DPOOL_DEFAULT)
397 dirty_rect.left = box->x << This->level_actual;
398 dirty_rect.right = dirty_rect.left + (box->width << This->level_actual);
399 dirty_rect.top = box->y << This->level_actual;
400 dirty_rect.bottom = dirty_rect.top + (box->height << This->level_actual);
402 if (This->texture == D3DRTYPE_TEXTURE) {
404 NineTexture9(This->base.base.container);
407 } else if (This->texture == D3DRTYPE_CUBETEXTURE) {
409 NineCubeTexture9(This->base.base.container);
411 NineCubeTexture9_AddDirtyRect(ctex, This->layer, &dirty_rect);
427 NineSurface9_LockRect( struct NineSurface9 *This,
432 struct pipe_resource *resource = This->base.resource;
437 DBG("This=%p pLockedRect=%p pRect=%p[%u..%u,%u..%u] Flags=%s\n", This,
442 NineSurface9_Dump(This);
445 user_assert(This->lock_count == 0, D3DERR_INVALIDCALL);
452 user_assert(This->base.pool != D3DPOOL_DEFAULT ||
459 user_assert(This->desc.MultiSampleType == D3DMULTISAMPLE_NONE,
462 if (pRect && This->desc.Pool == D3DPOOL_DEFAULT &&
463 util_format_is_compressed(This->base.info.format)) {
464 const unsigned w = util_format_get_blockwidth(This->base.info.format);
465 const unsigned h = util_format_get_blockheight(This->base.info.format);
466 user_assert((pRect->left == 0 && pRect->right == This->desc.Width &&
467 pRect->top == 0 && pRect->bottom == This->desc.Height) ||
487 u_box_origin_2d(This->desc.Width, This->desc.Height, &box);
489 box.z = This->layer;
491 user_warn(This->desc.Format == D3DFMT_NULL);
493 if (p_atomic_read(&This->pending_uploads_counter))
494 nine_csmt_process(This->base.base.device);
496 if (This->data_internal || This->data) {
497 enum pipe_format format = This->base.info.format;
498 unsigned stride = This->stride;
499 uint8_t *data = nine_get_pointer(This->base.base.device->allocator, This->data_internal ? This->data_internal : This->data);
500 if (This->data_internal) {
501 format = This->format_internal;
502 stride = This->stride_internal;
509 pLockedRect->Pitch = This->desc.Width;
510 pLockedRect->pBits = data + box.y * This->desc.Width + box.x;
521 bool no_refs = !p_atomic_read(&This->base.base.bind) &&
522 !(This->base.base.container && p_atomic_read(&This->base.base.container->bind));
524 resource, This->level, usage);
529 pipe = nine_context_get_pipe_acquire(This->base.base.device);
531 pipe = NineDevice9_GetPipe(This->base.base.device);
533 This->level, usage, &box,
534 &This->transfer);
536 nine_context_get_pipe_release(This->base.base.device);
537 if (!This->transfer) {
543 pLockedRect->Pitch = This->transfer->stride;
547 NineSurface9_MarkContainerDirty(This);
548 NineSurface9_AddDirtyRect(This, &box);
551 ++This->lock_count;
556 NineSurface9_UnlockRect( struct NineSurface9 *This )
560 DBG("This=%p lock_count=%u\n", This, This->lock_count);
561 user_assert(This->lock_count, D3DERR_INVALIDCALL);
562 if (This->transfer) {
563 pipe = nine_context_get_pipe_acquire(This->base.base.device);
564 pipe->texture_unmap(pipe, This->transfer);
565 nine_context_get_pipe_release(This->base.base.device);
566 This->transfer = NULL;
568 --This->lock_count;
570 if (This->data_internal) {
571 nine_pointer_weakrelease(This->base.base.device->allocator, This->data_internal);
572 if (This->data) {
573 (void) util_format_translate(This->base.info.format,
574 nine_get_pointer(This->base.base.device->allocator, This->data),
575 This->stride,
577 This->format_internal,
578 nine_get_pointer(This->base.base.device->allocator, This->data_internal),
579 This->stride_internal,
581 This->desc.Width, This->desc.Height);
582 nine_pointer_weakrelease(This->base.base.device->allocator, This->data);
583 nine_pointer_strongrelease(This->base.base.device->allocator, This->data_internal);
585 u_box_2d_zslice(0, 0, This->layer,
586 This->desc.Width, This->desc.Height, &dst_box);
588 This->desc.Width, This->desc.Height, &src_box);
590 nine_context_box_upload(This->base.base.device,
591 &This->pending_uploads_counter,
592 (struct NineUnknown *)This,
593 This->base.resource,
594 This->level,
596 This->format_internal,
597 nine_get_pointer(This->base.base.device->allocator, This->data_internal),
598 This->stride_internal,
601 nine_pointer_delayedstrongrelease(This->base.base.device->allocator, This->data_internal, &This->pending_uploads_counter);
603 } else if (This->data) {
604 nine_pointer_weakrelease(This->base.base.device->allocator, This->data);
611 NineSurface9_GetDC( struct NineSurface9 *This,
618 NineSurface9_ReleaseDC( struct NineSurface9 *This,
644 /* When this function is called, we have already checked
647 NineSurface9_CopyMemToDefault( struct NineSurface9 *This,
652 struct pipe_resource *r_dst = This->base.resource;
656 assert(This->base.pool == D3DPOOL_DEFAULT &&
679 u_box_2d_zslice(dst_x, dst_y, This->layer,
684 if (This->data_internal) {
685 (void) util_format_translate(This->format_internal,
686 nine_get_pointer(This->base.base.device->allocator, This->data_internal),
687 This->stride_internal,
690 nine_get_pointer(This->base.base.device->allocator, From->data),
694 nine_pointer_weakrelease(This->base.base.device->allocator, From->data);
695 nine_pointer_strongrelease(This->base.base.device->allocator, This->data_internal);
698 nine_context_box_upload(This->base.base.device,
702 This->level,
705 nine_get_pointer(This->base.base.device->allocator, From->data),
709 nine_pointer_delayedstrongrelease(This->base.base.device->allocator, From->data, &From->pending_uploads_counter);
722 nine_csmt_process(This->base.base.device);
725 NineSurface9_MarkContainerDirty(This);
729 NineSurface9_CopyDefaultToMem( struct NineSurface9 *This,
739 assert(This->base.pool == D3DPOOL_SYSTEMMEM &&
742 assert(This->desc.Width == From->desc.Width);
743 assert(This->desc.Height == From->desc.Height);
745 u_box_origin_2d(This->desc.Width, This->desc.Height, &src_box);
748 if (p_atomic_read(&This->pending_uploads_counter))
749 nine_csmt_process(This->base.base.device);
751 pipe = NineDevice9_GetPipe(This->base.base.device);
755 p_dst = nine_get_pointer(This->base.base.device->allocator, This->data);
759 util_copy_rect(p_dst, This->base.info.format,
760 This->stride, 0, 0,
761 This->desc.Width, This->desc.Height,
767 nine_pointer_weakrelease(This->base.base.device->allocator, This->data);
775 NineSurface9_UploadSelf( struct NineSurface9 *This,
778 struct pipe_resource *res = This->base.resource;
781 DBG("This=%p damaged=%p\n", This, damaged);
783 assert(This->base.pool == D3DPOOL_MANAGED);
787 box.z = This->layer;
792 box.z = This->layer;
793 box.width = This->desc.Width;
794 box.height = This->desc.Height;
798 nine_context_box_upload(This->base.base.device,
799 &This->pending_uploads_counter,
800 (struct NineUnknown *)This,
802 This->level,
805 nine_get_pointer(This->base.base.device->allocator, This->data),
806 This->stride,
809 nine_pointer_delayedstrongrelease(This->base.base.device->allocator, This->data, &This->pending_uploads_counter);
823 NineSurface9_SetResource( struct NineSurface9 *This,
828 assert(This->base.pool == D3DPOOL_MANAGED);
829 This->level = level;
830 pipe_resource_reference(&This->base.resource, resource);
834 NineSurface9_SetMultiSampleType( struct NineSurface9 *This,
837 PROCESS_IF_BOUND(This);
838 This->desc.MultiSampleType = mst;
842 NineSurface9_SetResourceResize( struct NineSurface9 *This,
845 assert(This->level == 0 && This->level_actual == 0);
846 assert(!This->lock_count);
847 assert(This->desc.Pool == D3DPOOL_DEFAULT);
848 assert(!This->texture);
850 PROCESS_IF_BOUND(This);
851 pipe_resource_reference(&This->base.resource, resource);
853 This->desc.Width = This->base.info.width0 = resource->width0;
854 This->desc.Height = This->base.info.height0 = resource->height0;
855 This->base.info.nr_samples = resource->nr_samples;
856 This->base.info.nr_storage_samples = resource->nr_storage_samples;
858 This->stride = nine_format_get_stride(This->base.info.format,
859 This->desc.Width);
861 pipe_surface_reference(&This->surface[0], NULL);
862 pipe_surface_reference(&This->surface[1], NULL);
863 NineSurface9_CreatePipeSurfaces(This);