996cde807d0a318a3ff994e3f3320c20ad80a10d
[mesa.git] / src / gallium / state_trackers / nine / surface9.c
1 /*
2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #include "surface9.h"
24 #include "device9.h"
25
26 /* for marking dirty */
27 #include "basetexture9.h"
28 #include "texture9.h"
29 #include "cubetexture9.h"
30
31 #include "nine_helpers.h"
32 #include "nine_pipe.h"
33 #include "nine_dump.h"
34
35 #include "pipe/p_context.h"
36 #include "pipe/p_screen.h"
37 #include "pipe/p_state.h"
38
39 #include "util/u_math.h"
40 #include "util/u_inlines.h"
41 #include "util/u_surface.h"
42
43 #define DBG_CHANNEL DBG_SURFACE
44
45 #define is_ATI1_ATI2(format) (format == PIPE_FORMAT_RGTC1_UNORM || format == PIPE_FORMAT_RGTC2_UNORM)
46
47 HRESULT
48 NineSurface9_ctor( struct NineSurface9 *This,
49 struct NineUnknownParams *pParams,
50 struct NineUnknown *pContainer,
51 struct pipe_resource *pResource,
52 void *user_buffer,
53 uint8_t TextureType,
54 unsigned Level,
55 unsigned Layer,
56 D3DSURFACE_DESC *pDesc )
57 {
58 HRESULT hr;
59 union pipe_color_union rgba = {0};
60 struct pipe_surface *surf;
61 struct pipe_context *pipe = pParams->device->pipe;
62
63 DBG("This=%p pDevice=%p pResource=%p Level=%u Layer=%u pDesc=%p\n",
64 This, pParams->device, pResource, Level, Layer, pDesc);
65
66 /* Mark this as a special surface held by another internal resource. */
67 pParams->container = pContainer;
68
69 user_assert(!(pDesc->Usage & D3DUSAGE_DYNAMIC) ||
70 (pDesc->Pool != D3DPOOL_MANAGED), D3DERR_INVALIDCALL);
71
72 assert(pResource || (user_buffer && pDesc->Pool != D3DPOOL_DEFAULT) ||
73 (!pContainer && pDesc->Pool != D3DPOOL_DEFAULT) ||
74 pDesc->Format == D3DFMT_NULL);
75
76 assert(!pResource || !user_buffer);
77 assert(!user_buffer || pDesc->Pool != D3DPOOL_DEFAULT);
78 /* The only way we can have !pContainer is being created
79 * from create_zs_or_rt_surface with params 0 0 0 */
80 assert(pContainer || (Level == 0 && Layer == 0 && TextureType == 0));
81
82 This->data = (uint8_t *)user_buffer;
83
84 This->base.info.screen = pParams->device->screen;
85 This->base.info.target = PIPE_TEXTURE_2D;
86 This->base.info.width0 = pDesc->Width;
87 This->base.info.height0 = pDesc->Height;
88 This->base.info.depth0 = 1;
89 This->base.info.last_level = 0;
90 This->base.info.array_size = 1;
91 This->base.info.nr_samples = pDesc->MultiSampleType;
92 This->base.info.usage = PIPE_USAGE_DEFAULT;
93 This->base.info.bind = PIPE_BIND_SAMPLER_VIEW;
94 This->base.info.flags = 0;
95 This->base.info.format = d3d9_to_pipe_format_checked(This->base.info.screen,
96 pDesc->Format,
97 This->base.info.target,
98 This->base.info.nr_samples,
99 This->base.info.bind,
100 FALSE);
101
102 if (pDesc->Usage & D3DUSAGE_RENDERTARGET)
103 This->base.info.bind |= PIPE_BIND_RENDER_TARGET;
104 if (pDesc->Usage & D3DUSAGE_DEPTHSTENCIL)
105 This->base.info.bind |= PIPE_BIND_DEPTH_STENCIL;
106
107 /* Ram buffer with no parent. Has to allocate the resource itself */
108 if (!pResource && !pContainer) {
109 assert(!user_buffer);
110 This->data = align_malloc(
111 nine_format_get_level_alloc_size(This->base.info.format,
112 pDesc->Width,
113 pDesc->Height,
114 0), 32);
115 if (!This->data)
116 return E_OUTOFMEMORY;
117 }
118
119 if (pDesc->Pool == D3DPOOL_SYSTEMMEM) {
120 This->base.info.usage = PIPE_USAGE_STAGING;
121 assert(!pResource);
122 } else {
123 if (pResource && (pDesc->Usage & D3DUSAGE_DYNAMIC))
124 pResource->flags |= NINE_RESOURCE_FLAG_LOCKABLE;
125 }
126
127 hr = NineResource9_ctor(&This->base, pParams, pResource, FALSE, D3DRTYPE_SURFACE,
128 pDesc->Pool, pDesc->Usage);
129 if (FAILED(hr))
130 return hr;
131
132 This->pipe = This->base.base.device->pipe;
133 This->transfer = NULL;
134
135 This->texture = TextureType;
136 This->level = Level;
137 This->level_actual = Level;
138 This->layer = Layer;
139 This->desc = *pDesc;
140
141 This->stride = nine_format_get_stride(This->base.info.format, pDesc->Width);
142
143 if (pResource && NineSurface9_IsOffscreenPlain(This))
144 pResource->flags |= NINE_RESOURCE_FLAG_LOCKABLE;
145
146 /* TODO: investigate what else exactly needs to be cleared */
147 if (This->base.resource && (pDesc->Usage & D3DUSAGE_RENDERTARGET)) {
148 surf = NineSurface9_GetSurface(This, 0);
149 pipe->clear_render_target(pipe, surf, &rgba, 0, 0, pDesc->Width, pDesc->Height);
150 }
151
152 NineSurface9_Dump(This);
153
154 return D3D_OK;
155 }
156
157 void
158 NineSurface9_dtor( struct NineSurface9 *This )
159 {
160 if (This->transfer)
161 NineSurface9_UnlockRect(This);
162
163 pipe_surface_reference(&This->surface[0], NULL);
164 pipe_surface_reference(&This->surface[1], NULL);
165
166 /* Release system memory when we have to manage it (no parent) */
167 if (!This->base.base.container && This->data)
168 FREE(This->data);
169 NineResource9_dtor(&This->base);
170 }
171
172 struct pipe_surface *
173 NineSurface9_CreatePipeSurface( struct NineSurface9 *This, const int sRGB )
174 {
175 struct pipe_context *pipe = This->pipe;
176 struct pipe_screen *screen = pipe->screen;
177 struct pipe_resource *resource = This->base.resource;
178 struct pipe_surface templ;
179 enum pipe_format srgb_format;
180
181 assert(This->desc.Pool == D3DPOOL_DEFAULT);
182 assert(resource);
183
184 srgb_format = util_format_srgb(resource->format);
185 if (sRGB && srgb_format != PIPE_FORMAT_NONE &&
186 screen->is_format_supported(screen, srgb_format,
187 resource->target, 0, resource->bind))
188 templ.format = srgb_format;
189 else
190 templ.format = resource->format;
191 templ.u.tex.level = This->level;
192 templ.u.tex.first_layer = This->layer;
193 templ.u.tex.last_layer = This->layer;
194
195 This->surface[sRGB] = pipe->create_surface(pipe, resource, &templ);
196 assert(This->surface[sRGB]);
197 return This->surface[sRGB];
198 }
199
200 #ifdef DEBUG
201 void
202 NineSurface9_Dump( struct NineSurface9 *This )
203 {
204 struct NineBaseTexture9 *tex;
205 GUID id = IID_IDirect3DBaseTexture9;
206 REFIID ref = &id;
207
208 DBG("\nNineSurface9(%p->%p/%p): Pool=%s Type=%s Usage=%s\n"
209 "Dims=%ux%u Format=%s Stride=%u Lockable=%i\n"
210 "Level=%u(%u), Layer=%u\n", This, This->base.resource, This->data,
211 nine_D3DPOOL_to_str(This->desc.Pool),
212 nine_D3DRTYPE_to_str(This->desc.Type),
213 nine_D3DUSAGE_to_str(This->desc.Usage),
214 This->desc.Width, This->desc.Height,
215 d3dformat_to_string(This->desc.Format), This->stride,
216 This->base.resource &&
217 (This->base.resource->flags & NINE_RESOURCE_FLAG_LOCKABLE),
218 This->level, This->level_actual, This->layer);
219
220 if (!This->base.base.container)
221 return;
222 NineUnknown_QueryInterface(This->base.base.container, ref, (void **)&tex);
223 if (tex) {
224 NineBaseTexture9_Dump(tex);
225 NineUnknown_Release(NineUnknown(tex));
226 }
227 }
228 #endif /* DEBUG */
229
230 HRESULT WINAPI
231 NineSurface9_GetContainer( struct NineSurface9 *This,
232 REFIID riid,
233 void **ppContainer )
234 {
235 HRESULT hr;
236 if (!NineUnknown(This)->container)
237 return E_NOINTERFACE;
238 hr = NineUnknown_QueryInterface(NineUnknown(This)->container, riid, ppContainer);
239 if (FAILED(hr))
240 DBG("QueryInterface FAILED!\n");
241 return hr;
242 }
243
244 void
245 NineSurface9_MarkContainerDirty( struct NineSurface9 *This )
246 {
247 if (This->texture) {
248 struct NineBaseTexture9 *tex =
249 NineBaseTexture9(This->base.base.container);
250 assert(tex);
251 assert(This->texture == D3DRTYPE_TEXTURE ||
252 This->texture == D3DRTYPE_CUBETEXTURE);
253 if (This->base.pool == D3DPOOL_MANAGED)
254 tex->managed.dirty = TRUE;
255 else
256 if (This->base.usage & D3DUSAGE_AUTOGENMIPMAP)
257 tex->dirty_mip = TRUE;
258
259 BASETEX_REGISTER_UPDATE(tex);
260 }
261 }
262
263 HRESULT WINAPI
264 NineSurface9_GetDesc( struct NineSurface9 *This,
265 D3DSURFACE_DESC *pDesc )
266 {
267 user_assert(pDesc != NULL, E_POINTER);
268 *pDesc = This->desc;
269 return D3D_OK;
270 }
271
272 /* Add the dirty rects to the source texture */
273 inline void
274 NineSurface9_AddDirtyRect( struct NineSurface9 *This,
275 const struct pipe_box *box )
276 {
277 RECT dirty_rect;
278
279 DBG("This=%p box=%p\n", This, box);
280
281 assert (This->base.pool != D3DPOOL_MANAGED ||
282 This->texture == D3DRTYPE_CUBETEXTURE ||
283 This->texture == D3DRTYPE_TEXTURE);
284
285 if (This->base.pool == D3DPOOL_DEFAULT)
286 return;
287
288 /* Add a dirty rect to level 0 of the parent texture */
289 dirty_rect.left = box->x << This->level_actual;
290 dirty_rect.right = dirty_rect.left + (box->width << This->level_actual);
291 dirty_rect.top = box->y << This->level_actual;
292 dirty_rect.bottom = dirty_rect.top + (box->height << This->level_actual);
293
294 if (This->texture == D3DRTYPE_TEXTURE) {
295 struct NineTexture9 *tex =
296 NineTexture9(This->base.base.container);
297
298 NineTexture9_AddDirtyRect(tex, &dirty_rect);
299 } else if (This->texture == D3DRTYPE_CUBETEXTURE) {
300 struct NineCubeTexture9 *ctex =
301 NineCubeTexture9(This->base.base.container);
302
303 NineCubeTexture9_AddDirtyRect(ctex, This->layer, &dirty_rect);
304 }
305 }
306
307 static inline uint8_t *
308 NineSurface9_GetSystemMemPointer(struct NineSurface9 *This, int x, int y)
309 {
310 unsigned x_offset = util_format_get_stride(This->base.info.format, x);
311
312 y = util_format_get_nblocksy(This->base.info.format, y);
313
314 assert(This->data);
315 return This->data + (y * This->stride + x_offset);
316 }
317
318 HRESULT WINAPI
319 NineSurface9_LockRect( struct NineSurface9 *This,
320 D3DLOCKED_RECT *pLockedRect,
321 const RECT *pRect,
322 DWORD Flags )
323 {
324 struct pipe_resource *resource = This->base.resource;
325 struct pipe_box box;
326 unsigned usage;
327
328 DBG("This=%p pLockedRect=%p pRect=%p[%u..%u,%u..%u] Flags=%s\n", This,
329 pLockedRect, pRect,
330 pRect ? pRect->left : 0, pRect ? pRect->right : 0,
331 pRect ? pRect->top : 0, pRect ? pRect->bottom : 0,
332 nine_D3DLOCK_to_str(Flags));
333 NineSurface9_Dump(This);
334
335 /* check if it's already locked */
336 user_assert(This->lock_count == 0, D3DERR_INVALIDCALL);
337
338 /* set pBits to NULL after lock_count check */
339 user_assert(pLockedRect, E_POINTER);
340 pLockedRect->pBits = NULL;
341
342 #ifdef NINE_STRICT
343 user_assert(This->base.pool != D3DPOOL_DEFAULT ||
344 (resource && (resource->flags & NINE_RESOURCE_FLAG_LOCKABLE)),
345 D3DERR_INVALIDCALL);
346 #endif
347 user_assert(!(Flags & ~(D3DLOCK_DISCARD |
348 D3DLOCK_DONOTWAIT |
349 D3DLOCK_NO_DIRTY_UPDATE |
350 D3DLOCK_NOOVERWRITE |
351 D3DLOCK_NOSYSLOCK | /* ignored */
352 D3DLOCK_READONLY)), D3DERR_INVALIDCALL);
353 user_assert(!((Flags & D3DLOCK_DISCARD) && (Flags & D3DLOCK_READONLY)),
354 D3DERR_INVALIDCALL);
355
356 user_assert(This->desc.MultiSampleType == D3DMULTISAMPLE_NONE,
357 D3DERR_INVALIDCALL);
358
359 if (pRect && This->desc.Pool == D3DPOOL_DEFAULT &&
360 compressed_format (This->desc.Format)) {
361 const unsigned w = util_format_get_blockwidth(This->base.info.format);
362 const unsigned h = util_format_get_blockheight(This->base.info.format);
363 user_assert((pRect->left == 0 && pRect->right == This->desc.Width &&
364 pRect->top == 0 && pRect->bottom == This->desc.Height) ||
365 (!(pRect->left % w) && !(pRect->right % w) &&
366 !(pRect->top % h) && !(pRect->bottom % h)),
367 D3DERR_INVALIDCALL);
368 }
369
370 if (Flags & D3DLOCK_DISCARD) {
371 usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE;
372 } else {
373 usage = (Flags & D3DLOCK_READONLY) ?
374 PIPE_TRANSFER_READ : PIPE_TRANSFER_READ_WRITE;
375 }
376 if (Flags & D3DLOCK_DONOTWAIT)
377 usage |= PIPE_TRANSFER_DONTBLOCK;
378
379 if (pRect) {
380 /* Windows XP accepts invalid locking rectangles, Windows 7 rejects
381 * them. Use Windows XP behaviour for now. */
382 rect_to_pipe_box(&box, pRect);
383 } else {
384 u_box_origin_2d(This->desc.Width, This->desc.Height, &box);
385 }
386
387 user_warn(This->desc.Format == D3DFMT_NULL);
388
389 if (This->data) {
390 DBG("returning system memory\n");
391 /* ATI1 and ATI2 need special handling, because of d3d9 bug.
392 * We must advertise to the application as if it is uncompressed
393 * and bpp 8, and the app has a workaround to work with the fact
394 * that it is actually compressed. */
395 if (is_ATI1_ATI2(This->base.info.format)) {
396 pLockedRect->Pitch = This->desc.Width;
397 pLockedRect->pBits = This->data + box.y * This->desc.Width + box.x;
398 } else {
399 pLockedRect->Pitch = This->stride;
400 pLockedRect->pBits = NineSurface9_GetSystemMemPointer(This,
401 box.x,
402 box.y);
403 }
404 } else {
405 DBG("mapping pipe_resource %p (level=%u usage=%x)\n",
406 resource, This->level, usage);
407
408 pLockedRect->pBits = This->pipe->transfer_map(This->pipe, resource,
409 This->level, usage, &box,
410 &This->transfer);
411 if (!This->transfer) {
412 DBG("transfer_map failed\n");
413 if (Flags & D3DLOCK_DONOTWAIT)
414 return D3DERR_WASSTILLDRAWING;
415 return D3DERR_INVALIDCALL;
416 }
417 pLockedRect->Pitch = This->transfer->stride;
418 }
419
420 if (!(Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY))) {
421 NineSurface9_MarkContainerDirty(This);
422 NineSurface9_AddDirtyRect(This, &box);
423 }
424
425 ++This->lock_count;
426 return D3D_OK;
427 }
428
429 HRESULT WINAPI
430 NineSurface9_UnlockRect( struct NineSurface9 *This )
431 {
432 DBG("This=%p lock_count=%u\n", This, This->lock_count);
433 user_assert(This->lock_count, D3DERR_INVALIDCALL);
434 if (This->transfer) {
435 This->pipe->transfer_unmap(This->pipe, This->transfer);
436 This->transfer = NULL;
437 }
438 --This->lock_count;
439 return D3D_OK;
440 }
441
442 HRESULT WINAPI
443 NineSurface9_GetDC( struct NineSurface9 *This,
444 HDC *phdc )
445 {
446 STUB(D3DERR_INVALIDCALL);
447 }
448
449 HRESULT WINAPI
450 NineSurface9_ReleaseDC( struct NineSurface9 *This,
451 HDC hdc )
452 {
453 STUB(D3DERR_INVALIDCALL);
454 }
455
456 IDirect3DSurface9Vtbl NineSurface9_vtable = {
457 (void *)NineUnknown_QueryInterface,
458 (void *)NineUnknown_AddRef,
459 (void *)NineUnknown_Release,
460 (void *)NineUnknown_GetDevice, /* actually part of Resource9 iface */
461 (void *)NineResource9_SetPrivateData,
462 (void *)NineResource9_GetPrivateData,
463 (void *)NineResource9_FreePrivateData,
464 (void *)NineResource9_SetPriority,
465 (void *)NineResource9_GetPriority,
466 (void *)NineResource9_PreLoad,
467 (void *)NineResource9_GetType,
468 (void *)NineSurface9_GetContainer,
469 (void *)NineSurface9_GetDesc,
470 (void *)NineSurface9_LockRect,
471 (void *)NineSurface9_UnlockRect,
472 (void *)NineSurface9_GetDC,
473 (void *)NineSurface9_ReleaseDC
474 };
475
476 /* When this function is called, we have already checked
477 * The copy regions fit the surfaces */
478 void
479 NineSurface9_CopyMemToDefault( struct NineSurface9 *This,
480 struct NineSurface9 *From,
481 const POINT *pDestPoint,
482 const RECT *pSourceRect )
483 {
484 struct pipe_context *pipe = This->pipe;
485 struct pipe_resource *r_dst = This->base.resource;
486 struct pipe_box dst_box;
487 const uint8_t *p_src;
488 int src_x, src_y, dst_x, dst_y, copy_width, copy_height;
489
490 assert(This->base.pool == D3DPOOL_DEFAULT &&
491 From->base.pool == D3DPOOL_SYSTEMMEM);
492
493 if (pDestPoint) {
494 dst_x = pDestPoint->x;
495 dst_y = pDestPoint->y;
496 } else {
497 dst_x = 0;
498 dst_y = 0;
499 }
500
501 if (pSourceRect) {
502 src_x = pSourceRect->left;
503 src_y = pSourceRect->top;
504 copy_width = pSourceRect->right - pSourceRect->left;
505 copy_height = pSourceRect->bottom - pSourceRect->top;
506 } else {
507 src_x = 0;
508 src_y = 0;
509 copy_width = From->desc.Width;
510 copy_height = From->desc.Height;
511 }
512
513 u_box_2d_zslice(dst_x, dst_y, This->layer,
514 copy_width, copy_height, &dst_box);
515
516 p_src = NineSurface9_GetSystemMemPointer(From, src_x, src_y);
517
518 pipe->transfer_inline_write(pipe, r_dst, This->level,
519 0, /* WRITE|DISCARD are implicit */
520 &dst_box, p_src, From->stride, 0);
521
522 NineSurface9_MarkContainerDirty(This);
523 }
524
525 void
526 NineSurface9_CopyDefaultToMem( struct NineSurface9 *This,
527 struct NineSurface9 *From )
528 {
529 struct pipe_context *pipe = This->pipe;
530 struct pipe_resource *r_src = From->base.resource;
531 struct pipe_transfer *transfer;
532 struct pipe_box src_box;
533 uint8_t *p_dst;
534 const uint8_t *p_src;
535
536 assert(This->base.pool == D3DPOOL_SYSTEMMEM &&
537 From->base.pool == D3DPOOL_DEFAULT);
538
539 assert(This->desc.Width == From->desc.Width);
540 assert(This->desc.Height == From->desc.Height);
541
542 u_box_origin_2d(This->desc.Width, This->desc.Height, &src_box);
543 src_box.z = From->layer;
544
545 p_src = pipe->transfer_map(pipe, r_src, From->level,
546 PIPE_TRANSFER_READ,
547 &src_box, &transfer);
548 p_dst = NineSurface9_GetSystemMemPointer(This, 0, 0);
549
550 assert (p_src && p_dst);
551
552 util_copy_rect(p_dst, This->base.info.format,
553 This->stride, 0, 0,
554 This->desc.Width, This->desc.Height,
555 p_src,
556 transfer->stride, 0, 0);
557
558 pipe->transfer_unmap(pipe, transfer);
559 }
560
561
562 /* Gladly, rendering to a MANAGED surface is not permitted, so we will
563 * never have to do the reverse, i.e. download the surface.
564 */
565 HRESULT
566 NineSurface9_UploadSelf( struct NineSurface9 *This,
567 const struct pipe_box *damaged )
568 {
569 struct pipe_context *pipe = This->pipe;
570 struct pipe_resource *res = This->base.resource;
571 uint8_t *ptr;
572 struct pipe_box box;
573
574 DBG("This=%p damaged=%p\n", This, damaged);
575
576 assert(This->base.pool == D3DPOOL_MANAGED);
577
578 if (damaged) {
579 box = *damaged;
580 box.z = This->layer;
581 box.depth = 1;
582 } else {
583 box.x = 0;
584 box.y = 0;
585 box.z = This->layer;
586 box.width = This->desc.Width;
587 box.height = This->desc.Height;
588 box.depth = 1;
589 }
590
591 ptr = NineSurface9_GetSystemMemPointer(This, box.x, box.y);
592
593 pipe->transfer_inline_write(pipe, res, This->level, 0,
594 &box, ptr, This->stride, 0);
595
596 return D3D_OK;
597 }
598
599 void
600 NineSurface9_SetResourceResize( struct NineSurface9 *This,
601 struct pipe_resource *resource )
602 {
603 assert(This->level == 0 && This->level_actual == 0);
604 assert(!This->lock_count);
605 assert(This->desc.Pool == D3DPOOL_DEFAULT);
606 assert(!This->texture);
607
608 pipe_resource_reference(&This->base.resource, resource);
609
610 This->desc.Width = This->base.info.width0 = resource->width0;
611 This->desc.Height = This->base.info.height0 = resource->height0;
612 This->desc.MultiSampleType = This->base.info.nr_samples = resource->nr_samples;
613
614 This->stride = nine_format_get_stride(This->base.info.format,
615 This->desc.Width);
616
617 pipe_surface_reference(&This->surface[0], NULL);
618 pipe_surface_reference(&This->surface[1], NULL);
619 }
620
621
622 static const GUID *NineSurface9_IIDs[] = {
623 &IID_IDirect3DSurface9,
624 &IID_IDirect3DResource9,
625 &IID_IUnknown,
626 NULL
627 };
628
629 HRESULT
630 NineSurface9_new( struct NineDevice9 *pDevice,
631 struct NineUnknown *pContainer,
632 struct pipe_resource *pResource,
633 void *user_buffer,
634 uint8_t TextureType,
635 unsigned Level,
636 unsigned Layer,
637 D3DSURFACE_DESC *pDesc,
638 struct NineSurface9 **ppOut )
639 {
640 NINE_DEVICE_CHILD_NEW(Surface9, ppOut, pDevice, /* args */
641 pContainer, pResource, user_buffer,
642 TextureType, Level, Layer, pDesc);
643 }