1 /**************************************************************************
3 * Copyright 2010 Luca Barbieri
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
27 template<typename Base
= ID3D11DeviceChild
>
28 struct GalliumD3D11DeviceChild
: public GalliumPrivateDataComObject
<Base
, dual_refcnt_t
>
30 GalliumD3D11Screen
* device
; // must not be null
33 // if this is called, the subclass constructor must set device itself
34 GalliumD3D11DeviceChild()
38 GalliumD3D11DeviceChild(GalliumD3D11Screen
* p_device
)
40 // we store the reference count minus one in refcnt
45 /* The purpose of this is to avoid cyclic garbage, since this won't hold
46 * a pointer to the device if it is only held by a pipeline binding in the immediate context
48 * TODO: we could only manipulate the device refcnt when atomic_refcnt == 0 changes,
49 * but this requires more complex atomic ops
51 inline ULONG
add_ref()
54 return GalliumPrivateDataComObject
<Base
, dual_refcnt_t
>::add_ref();
57 inline ULONG
release()
60 return GalliumPrivateDataComObject
<Base
, dual_refcnt_t
>::release();
63 virtual ULONG STDMETHODCALLTYPE
AddRef()
68 virtual ULONG STDMETHODCALLTYPE
Release()
73 virtual void STDMETHODCALLTYPE
GetDevice(
74 __out ID3D11Device
**ppDevice
82 template<typename Base
= ID3D11DeviceChild
, typename Object
= void>
83 struct GalliumD3D11Object
: public GalliumD3D11DeviceChild
<Base
>
86 GalliumD3D11Object(GalliumD3D11Screen
* device
, Object
* object
)
87 : GalliumD3D11DeviceChild
<Base
>(device
), object(object
)
90 virtual ~GalliumD3D11Object();
93 #define IMPLEMENT_OBJECT_DTOR(name, gallium) \
95 GalliumD3D11Object<ID3D11##name, void>::~GalliumD3D11Object() \
97 DX10_ONLY(device->Unbind##name(this)); \
98 device->immediate_pipe->delete_##gallium##_state(device->immediate_pipe, object); \
101 #define IMPLEMENT_VIEW_DTOR(name, gallium) \
103 GalliumD3D11Object<ID3D11##name, struct pipe_##gallium>::~GalliumD3D11Object() \
105 DX10_ONLY(device->Unbind##name(this)); \
106 pipe_##gallium##_reference(&object, 0); \
109 IMPLEMENT_OBJECT_DTOR(InputLayout
, vertex_elements
)
110 IMPLEMENT_OBJECT_DTOR(DepthStencilState
, depth_stencil_alpha
)
111 IMPLEMENT_OBJECT_DTOR(RasterizerState
, rasterizer
)
112 IMPLEMENT_OBJECT_DTOR(SamplerState
, sampler
)
113 IMPLEMENT_OBJECT_DTOR(BlendState
, blend
)
114 IMPLEMENT_OBJECT_DTOR(VertexShader
, vs
)
115 IMPLEMENT_OBJECT_DTOR(PixelShader
, fs
)
116 IMPLEMENT_OBJECT_DTOR(GeometryShader
, gs
)
118 IMPLEMENT_VIEW_DTOR(ShaderResourceView
, sampler_view
)
119 IMPLEMENT_VIEW_DTOR(RenderTargetView
, surface
)
120 IMPLEMENT_VIEW_DTOR(DepthStencilView
, surface
)
123 // IMPLEMENT_VIEW_DTOR(UnorderedAccessView, surface);
124 // IMPLEMENT_OBJECT_DTOR(HullShader, tcs);
125 // IMPLEMENT_OBJECT_DTOR(DomainShader, tes);
126 // IMPLEMENT_OBJECT_DTOR(ComputeShader, cs);
128 IMPLEMENT_OBJECT_DTOR(BlendState1
, blend
)
129 IMPLEMENT_VIEW_DTOR(ShaderResourceView1
, sampler_view
)
132 template<typename Base
, typename Desc
, typename Object
= void>
133 struct GalliumD3D11DescribedObject
: public GalliumD3D11Object
<Base
, Object
>
136 GalliumD3D11DescribedObject(GalliumD3D11Screen
* device
, Object
* object
, const Desc
& desc
)
137 : GalliumD3D11Object
<Base
, Object
>(device
, object
), desc(desc
)
140 virtual void STDMETHODCALLTYPE
GetDesc(Desc
*pDesc
)
142 memcpy(pDesc
, &desc
, sizeof(desc
));
146 typedef GalliumD3D11Object
<ID3D11InputLayout
> GalliumD3D11InputLayout
;
147 typedef GalliumD3D11DescribedObject
<ID3D11DepthStencilState
, D3D11_DEPTH_STENCIL_DESC
> GalliumD3D11DepthStencilState
;
148 typedef GalliumD3D11DescribedObject
<ID3D11RasterizerState
, D3D11_RASTERIZER_DESC
> GalliumD3D11RasterizerStateBase
;
149 typedef GalliumD3D11DescribedObject
<ID3D11SamplerState
, D3D11_SAMPLER_DESC
> GalliumD3D11SamplerState
;
152 typedef GalliumD3D11DescribedObject
<ID3D11BlendState
, D3D11_BLEND_DESC
> GalliumD3D11BlendState
;
154 typedef GalliumD3D10DescribedObject
<ID3D10BlendState1
, D3D10_BLEND_DESC
> GalliumD3D10BlendStateBase
;
156 struct GalliumD3D10BlendState
: public GalliumD3D10BlendStateBase
158 static D3D10_BLEND_DESC
convert_to_d3d10(const D3D10_BLEND_DESC1
& desc1
)
160 D3D10_BLEND_DESC desc
;
161 desc
.AlphaToCoverageEnable
= desc1
.AlphaToCoverageEnable
;
162 desc
.SrcBlend
= desc1
.RenderTarget
[0].SrcBlend
;
163 desc
.DestBlend
= desc1
.RenderTarget
[0].DestBlend
;
164 desc
.BlendOp
= desc1
.RenderTarget
[0].BlendOp
;
165 desc
.SrcBlendAlpha
= desc1
.RenderTarget
[0].SrcBlendAlpha
;
166 desc
.DestBlendAlpha
= desc1
.RenderTarget
[0].DestBlendAlpha
;
167 desc
.BlendOpAlpha
= desc1
.RenderTarget
[0].BlendOpAlpha
;
168 for(unsigned i
= 0; i
< 8; ++i
)
170 desc
.BlendEnable
[i
] = desc1
.RenderTarget
[i
].BlendEnable
;
171 desc
.RenderTargetWriteMask
[i
] = desc1
.RenderTarget
[i
].RenderTargetWriteMask
;
176 D3D10_BLEND_DESC1 desc1
;
178 GalliumD3D10BlendState(GalliumD3D10Screen
* device
, void* object
, const D3D10_BLEND_DESC
& desc
)
179 : GalliumD3D10BlendStateBase(device
, object
, desc
)
181 memset(&desc1
, 0, sizeof(desc1
));
182 desc1
.AlphaToCoverageEnable
= desc
.AlphaToCoverageEnable
;
183 desc1
.RenderTarget
[0].SrcBlend
= desc
.SrcBlend
;
184 desc1
.RenderTarget
[0].DestBlend
= desc
.DestBlend
;
185 desc1
.RenderTarget
[0].BlendOp
= desc
.BlendOp
;
186 desc1
.RenderTarget
[0].SrcBlendAlpha
= desc
.SrcBlendAlpha
;
187 desc1
.RenderTarget
[0].DestBlendAlpha
= desc
.DestBlendAlpha
;
188 desc1
.RenderTarget
[0].BlendOpAlpha
= desc
.BlendOpAlpha
;
189 for(unsigned i
= 0; i
< 8; ++i
)
191 desc1
.RenderTarget
[i
].BlendEnable
= desc
.BlendEnable
[i
];
192 desc1
.RenderTarget
[i
].RenderTargetWriteMask
= desc
.RenderTargetWriteMask
[i
];
196 GalliumD3D10BlendState(GalliumD3D10Screen
* device
, void* object
, const D3D10_BLEND_DESC1
& desc
)
197 : GalliumD3D10BlendStateBase(device
, object
, convert_to_d3d10(desc
)), desc1(desc1
)
200 virtual void STDMETHODCALLTYPE
GetDesc1(D3D10_BLEND_DESC1
*pDesc
)
202 memcpy(pDesc
, &desc1
, sizeof(desc1
));
207 struct GalliumD3D11RasterizerState
: public GalliumD3D11RasterizerStateBase
211 GalliumD3D11RasterizerState(GalliumD3D11Screen
* device
, void* object
, const D3D11_RASTERIZER_DESC
& desc
, bool depth_clamp
)
212 : GalliumD3D11RasterizerStateBase(device
, object
, desc
), depth_clamp(depth_clamp
)
216 template<typename Base
= ID3D11DeviceChild
>
217 struct GalliumD3D11Shader
: public GalliumD3D11Object
<Base
>
219 std::vector
<int> slot_to_resource
;
220 std::vector
<int> slot_to_sampler
;
222 GalliumD3D11Shader(GalliumD3D11Screen
* device
, void* object
)
223 : GalliumD3D11Object
<Base
>(device
, object
)
227 typedef GalliumD3D11Shader
<ID3D11VertexShader
> GalliumD3D11VertexShader
;
228 typedef GalliumD3D11Shader
<ID3D11GeometryShader
> GalliumD3D11GeometryShader
;
229 typedef GalliumD3D11Shader
<ID3D11PixelShader
> GalliumD3D11PixelShader
;
233 typedef GalliumD3D11Shader<ID3D11HullShader> GalliumD3D11HullShader;
234 typedef GalliumD3D11Shader<ID3D11DomainShader> GalliumD3D11DomainShader;
235 typedef GalliumD3D11Shader<ID3D11ComputeShader> GalliumD3D11ComputeShader;
239 template<typename Base
= ID3D11Resource
>
240 struct GalliumD3D11ResourceBase
: public GalliumD3D11DeviceChild
<Base
>
242 unsigned eviction_priority
;
244 virtual void STDMETHODCALLTYPE
SetEvictionPriority(
245 __in
unsigned EvictionPriority
)
247 eviction_priority
= EvictionPriority
;
250 virtual unsigned STDMETHODCALLTYPE
GetEvictionPriority()
252 return eviction_priority
;
256 template<typename Real
>
257 struct GalliumDXGIResource
: public IDXGIResource
259 virtual HRESULT STDMETHODCALLTYPE
SetEvictionPriority(
260 __in
unsigned EvictionPriority
)
262 static_cast<Real
*>(this)->eviction_priority
= EvictionPriority
;
266 virtual HRESULT STDMETHODCALLTYPE
GetEvictionPriority(unsigned* pEvictionPriority
)
268 *pEvictionPriority
= static_cast<Real
*>(this)->eviction_priority
;
272 virtual HRESULT STDMETHODCALLTYPE
GetDevice(
274 __out
void **ppParent
)
276 if(!static_cast<Real
*>(this)->device
)
277 return E_NOINTERFACE
;
278 return static_cast<Real
*>(this)->device
->QueryInterface(riid
, ppParent
);
281 virtual HRESULT STDMETHODCALLTYPE
GetParent(
283 __out
void **ppParent
)
285 if(!static_cast<Real
*>(this)->device
)
286 return E_NOINTERFACE
;
287 return static_cast<Real
*>(this)->device
->QueryInterface(riid
, ppParent
);
292 struct com_traits
<GalliumDXGIResource
<T
> > : public com_traits
<IDXGIResource
>
295 template<typename Base
= ID3D11Resource
>
296 struct GalliumD3D11Resource
297 : public GalliumMultiComObject
<
298 GalliumMultiPrivateDataComObject
<
299 GalliumD3D11ResourceBase
<Base
>,
300 GalliumDXGIResource
<GalliumD3D11Resource
<Base
> >
305 struct pipe_resource
* resource
;
306 std::unordered_map
<unsigned, pipe_transfer
*> transfers
;
308 DXGI_USAGE dxgi_usage
;
310 GalliumD3D11Resource(GalliumD3D11Screen
* device
= 0, struct pipe_resource
* resource
= 0, unsigned dxgi_usage
= 0)
311 : resource(resource
), min_lod(0), dxgi_usage(dxgi_usage
)
313 this->device
= device
;
316 this->eviction_priority
= 0;
319 ~GalliumD3D11Resource()
321 pipe_resource_reference(&resource
, 0);
324 virtual HRESULT STDMETHODCALLTYPE
GetUsage(
325 __out DXGI_USAGE
*pUsage
328 *pUsage
= this->dxgi_usage
;
332 virtual HRESULT STDMETHODCALLTYPE
GetSharedHandle(HANDLE
*pSharedHandle
)
337 virtual struct pipe_resource
* STDMETHODCALLTYPE
GetGalliumResource()
343 template<typename Base
, typename Desc
, D3D11_RESOURCE_DIMENSION Dim
>
344 struct GalliumD3D11TypedResource
: public GalliumD3D11Resource
<Base
>
347 GalliumD3D11TypedResource() {}
348 GalliumD3D11TypedResource(GalliumD3D11Screen
* device
, struct pipe_resource
* resource
, const Desc
& desc
, unsigned dxgi_usage
)
349 : GalliumD3D11Resource
<Base
>(device
, resource
, dxgi_usage
), desc(desc
)
351 virtual void STDMETHODCALLTYPE
GetType(
352 __out D3D11_RESOURCE_DIMENSION
*pResourceDimension
)
354 *pResourceDimension
= Dim
;
356 virtual void STDMETHODCALLTYPE
GetDesc(Desc
*pDesc
)
358 memcpy(pDesc
, &desc
, sizeof(desc
));
362 typedef GalliumD3D11TypedResource
<ID3D11Texture1D
, D3D11_TEXTURE1D_DESC
, D3D11_RESOURCE_DIMENSION_TEXTURE1D
> GalliumD3D11Texture1DBase
;
363 typedef GalliumD3D11TypedResource
<ID3D11Texture2D
, D3D11_TEXTURE2D_DESC
, D3D11_RESOURCE_DIMENSION_TEXTURE2D
> GalliumD3D11Texture2DBase
;
364 typedef GalliumD3D11TypedResource
<ID3D11Texture3D
, D3D11_TEXTURE3D_DESC
, D3D11_RESOURCE_DIMENSION_TEXTURE3D
> GalliumD3D11Texture3DBase
;
365 typedef GalliumD3D11TypedResource
<ID3D11Buffer
, D3D11_BUFFER_DESC
, D3D11_RESOURCE_DIMENSION_BUFFER
> GalliumD3D11BufferBase
;
368 typedef GalliumD3D11BufferBase GalliumD3D11Buffer
;
369 typedef GalliumD3D11Texture1DBase GalliumD3D11Texture1D
;
370 typedef GalliumD3D11Texture2DBase GalliumD3D11Texture2D
;
371 typedef GalliumD3D11Texture3DBase GalliumD3D11Texture3D
;
373 struct GalliumD3D10Buffer
: public GalliumD3D10BufferBase
375 GalliumD3D10Buffer(GalliumD3D10Screen
* device
, struct pipe_resource
* resource
, const D3D10_BUFFER_DESC
& desc
, unsigned dxgi_usage
)
376 : GalliumD3D10BufferBase(device
, resource
, desc
, dxgi_usage
)
379 ~GalliumD3D10Buffer()
381 device
->UnbindBuffer(this);
384 virtual HRESULT STDMETHODCALLTYPE
Map(
385 __in D3D10_MAP MapType
,
386 __in
unsigned MapFlags
,
389 D3D10_MAPPED_SUBRESOURCE msr
;
390 HRESULT hr
= device
->Map(this, 0, MapType
, MapFlags
, &msr
);
397 virtual void STDMETHODCALLTYPE
Unmap()
399 device
->Unmap(this, 0);
403 struct GalliumD3D10Texture1D
: public GalliumD3D10Texture1DBase
405 GalliumD3D10Texture1D(GalliumD3D10Screen
* device
, struct pipe_resource
* resource
, const D3D10_TEXTURE1D_DESC
& desc
, unsigned dxgi_usage
)
406 : GalliumD3D10Texture1DBase(device
, resource
, desc
, dxgi_usage
)
409 virtual HRESULT STDMETHODCALLTYPE
Map(
410 __in
unsigned Subresource
,
411 __in D3D10_MAP MapType
,
412 __in
unsigned MapFlags
,
415 D3D10_MAPPED_SUBRESOURCE msr
;
416 HRESULT hr
= device
->Map(this, Subresource
, MapType
, MapFlags
, &msr
);
423 virtual void STDMETHODCALLTYPE
Unmap(
424 __in
unsigned Subresource
427 device
->Unmap(this, Subresource
);
431 struct GalliumD3D10Texture2D
: public GalliumD3D10Texture2DBase
433 GalliumD3D10Texture2D() {}
434 GalliumD3D10Texture2D(GalliumD3D10Screen
* device
, struct pipe_resource
* resource
, const D3D10_TEXTURE2D_DESC
& desc
, unsigned dxgi_usage
)
435 : GalliumD3D10Texture2DBase(device
, resource
, desc
, dxgi_usage
)
438 virtual HRESULT STDMETHODCALLTYPE
Map(
439 __in
unsigned Subresource
,
440 __in D3D10_MAP MapType
,
441 __in
unsigned MapFlags
,
442 __out D3D10_MAPPED_TEXTURE2D
*pMappedTex2D
)
444 D3D10_MAPPED_SUBRESOURCE msr
;
445 HRESULT hr
= device
->Map(this, Subresource
, MapType
, MapFlags
, &msr
);
448 pMappedTex2D
->pData
= msr
.pData
;
449 pMappedTex2D
->RowPitch
= msr
.RowPitch
;
453 virtual void STDMETHODCALLTYPE
Unmap(
454 __in
unsigned Subresource
457 device
->Unmap(this, Subresource
);
462 struct GalliumD3D10Texture3D
: public GalliumD3D10Texture3DBase
464 GalliumD3D10Texture3D(GalliumD3D10Screen
* device
, struct pipe_resource
* resource
, const D3D10_TEXTURE3D_DESC
& desc
, unsigned dxgi_usage
)
465 : GalliumD3D10Texture3DBase(device
, resource
, desc
, dxgi_usage
)
468 virtual HRESULT STDMETHODCALLTYPE
Map(
469 __in
unsigned Subresource
,
470 __in D3D10_MAP MapType
,
471 __in
unsigned MapFlags
,
472 __out D3D10_MAPPED_TEXTURE3D
*pMappedTex3D
)
474 D3D10_MAPPED_SUBRESOURCE msr
;
475 HRESULT hr
= device
->Map(this, Subresource
, MapType
, MapFlags
, &msr
);
478 pMappedTex3D
->pData
= msr
.pData
;
479 pMappedTex3D
->RowPitch
= msr
.RowPitch
;
480 pMappedTex3D
->DepthPitch
= msr
.DepthPitch
;
484 virtual void STDMETHODCALLTYPE
Unmap(
485 __in
unsigned Subresource
488 device
->Unmap(this, Subresource
);
493 struct GalliumD3D11Surface
: public GalliumMultiPrivateDataComObject
<GalliumD3D11Texture2D
, IDXGISurface1
>
495 GalliumD3D11Surface(GalliumD3D11Screen
* device
, struct pipe_resource
* resource
, const D3D11_TEXTURE2D_DESC
& desc
, unsigned dxgi_usage
)
497 this->device
= device
;
498 this->device
->AddRef();
499 this->resource
= resource
;
501 this->dxgi_usage
= dxgi_usage
;
504 virtual HRESULT STDMETHODCALLTYPE
GetDesc(
505 __out DXGI_SURFACE_DESC
*pDesc
)
507 pDesc
->Format
= this->desc
.Format
;
508 pDesc
->Width
= this->desc
.Width
;
509 pDesc
->Height
= this->desc
.Height
;
510 pDesc
->SampleDesc
= this->desc
.SampleDesc
;
514 virtual HRESULT STDMETHODCALLTYPE
GetParent(
516 __out
void **ppParent
)
519 return E_NOINTERFACE
;
520 return device
->QueryInterface(riid
, ppParent
);
523 /* TODO: somehow implement these */
524 virtual HRESULT STDMETHODCALLTYPE
GetDC(
532 virtual HRESULT STDMETHODCALLTYPE
ReleaseDC(
533 __in_opt RECT
*pDirtyRect
)
538 virtual HRESULT STDMETHODCALLTYPE
Map(
539 __out DXGI_MAPPED_RECT
*pLockedRect
,
543 if(MapFlags
& DXGI_MAP_DISCARD
)
544 d3d_map
= D3D11_MAP_WRITE_DISCARD
;
547 if(MapFlags
& DXGI_MAP_READ
)
549 if(MapFlags
& DXGI_MAP_WRITE
)
550 d3d_map
= D3D11_MAP_READ_WRITE
;
552 d3d_map
= D3D11_MAP_READ
;
555 d3d_map
= D3D11_MAP_WRITE
;
557 D3D11_MAPPED_SUBRESOURCE d3d_mapped
;
558 HRESULT hres
= this->device
->get_immediate_context()->Map(this, 0, d3d_map
, 0, &d3d_mapped
);
559 pLockedRect
->pBits
= (uint8_t*)d3d_mapped
.pData
;
560 pLockedRect
->Pitch
= d3d_mapped
.RowPitch
;
564 virtual HRESULT STDMETHODCALLTYPE
Unmap(void)
566 this->device
->get_immediate_context()->Unmap(this, 0);
570 virtual HRESULT STDMETHODCALLTYPE
GetDevice(
572 __out
void **ppParent
)
575 return E_NOINTERFACE
;
576 return device
->QueryInterface(riid
, ppParent
);
580 template<typename Base
, typename Desc
, typename Object
>
581 struct GalliumD3D11View
: public GalliumD3D11DescribedObject
<Base
, Desc
, Object
>
583 GalliumD3D11Resource
<>* resource
;
584 GalliumD3D11View(GalliumD3D11Screen
* device
, GalliumD3D11Resource
<>* resource
, Object
* object
, const Desc
& desc
)
585 : GalliumD3D11DescribedObject
<Base
, Desc
, Object
>(device
, object
, desc
), resource(resource
)
595 virtual void STDMETHODCALLTYPE
GetResource(ID3D11Resource
** ppResource
)
598 *ppResource
= resource
;
602 typedef GalliumD3D11View
<ID3D11DepthStencilView
, D3D11_DEPTH_STENCIL_VIEW_DESC
, struct pipe_surface
> GalliumD3D11DepthStencilView
;
603 typedef GalliumD3D11View
<ID3D11RenderTargetView
, D3D11_RENDER_TARGET_VIEW_DESC
, struct pipe_surface
> GalliumD3D11RenderTargetView
;
606 typedef GalliumD3D11View
<ID3D11ShaderResourceView
, D3D11_SHADER_RESOURCE_VIEW_DESC
, struct pipe_sampler_view
> GalliumD3D11ShaderResourceView
;
608 typedef GalliumD3D10View
<ID3D10ShaderResourceView1
, D3D10_SHADER_RESOURCE_VIEW_DESC1
, struct pipe_sampler_view
> GalliumD3D10ShaderResourceViewBase
;
610 struct GalliumD3D10ShaderResourceView
: public GalliumD3D10ShaderResourceViewBase
612 GalliumD3D10ShaderResourceView(GalliumD3D10Screen
* device
, GalliumD3D10Resource
<>* resource
, struct pipe_sampler_view
* view
, const D3D10_SHADER_RESOURCE_VIEW_DESC1
& desc
)
613 : GalliumD3D10ShaderResourceViewBase(device
, resource
, view
, desc
)
616 virtual void STDMETHODCALLTYPE
GetDesc1(D3D10_SHADER_RESOURCE_VIEW_DESC1
*pDesc
)
618 memcpy(pDesc
, &desc
, sizeof(*pDesc
));
621 virtual void STDMETHODCALLTYPE
GetDesc(D3D10_SHADER_RESOURCE_VIEW_DESC
*pDesc
)
623 memcpy(pDesc
, &desc
, sizeof(*pDesc
));
628 template<typename Base
= ID3D11Asynchronous
>
629 struct GalliumD3D11Asynchronous
: public GalliumD3D11DeviceChild
<Base
>
631 struct pipe_query
* query
;
634 GalliumD3D11Asynchronous(GalliumD3D11Screen
* device
, struct pipe_query
* query
, unsigned data_size
)
635 : GalliumD3D11DeviceChild
<Base
>(device
), query(query
), data_size(data_size
)
638 ~GalliumD3D11Asynchronous()
640 this->device
->immediate_pipe
->destroy_query(this->device
->immediate_pipe
, query
);
643 virtual unsigned STDMETHODCALLTYPE
GetDataSize()
649 virtual void STDMETHODCALLTYPE
Begin()
651 this->device
->Begin(this);
654 virtual void STDMETHODCALLTYPE
End()
656 this->device
->End(this);
659 virtual HRESULT STDMETHODCALLTYPE
GetData(
660 __out_bcount(DataSize
) void *pData
,
661 __in
unsigned DataSize
,
662 __in
unsigned GetDataFlags
)
664 return this->device
->GetData(this, pData
, DataSize
, GetDataFlags
);
669 template<typename Base
= ID3D11Asynchronous
>
670 struct GalliumD3D11QueryOrPredicate
: public GalliumD3D11Asynchronous
<Base
>
672 D3D11_QUERY_DESC desc
;
673 GalliumD3D11QueryOrPredicate(GalliumD3D11Screen
* device
, struct pipe_query
* query
, unsigned data_size
, const D3D11_QUERY_DESC
& desc
)
674 : GalliumD3D11Asynchronous
<Base
>(device
, query
, data_size
), desc(desc
)
677 virtual void STDMETHODCALLTYPE
GetDesc(
678 __out D3D11_QUERY_DESC
*pDesc
)
684 struct GalliumD3D11Query
: public GalliumD3D11QueryOrPredicate
<ID3D11Query
>
686 GalliumD3D11Query(GalliumD3D11Screen
* device
, struct pipe_query
* query
, unsigned data_size
, const D3D11_QUERY_DESC
& desc
)
687 : GalliumD3D11QueryOrPredicate
<ID3D11Query
>(device
, query
, data_size
, desc
)
691 struct GalliumD3D11Predicate
: public GalliumD3D11QueryOrPredicate
<ID3D11Predicate
>
693 GalliumD3D11Predicate(GalliumD3D11Screen
* device
, struct pipe_query
* query
, unsigned data_size
, const D3D11_QUERY_DESC
& desc
)
694 : GalliumD3D11QueryOrPredicate
<ID3D11Predicate
>(device
, query
, data_size
, desc
)
697 ~GalliumD3D11Predicate()
699 DX10_ONLY(device
->UnbindPredicate(this));
703 struct GalliumD3D11Counter
: public GalliumD3D11Asynchronous
<ID3D11Counter
>
705 D3D11_COUNTER_DESC desc
;
706 GalliumD3D11Counter(GalliumD3D11Screen
* device
, struct pipe_query
* query
, unsigned data_size
, const D3D11_COUNTER_DESC
& desc
)
707 : GalliumD3D11Asynchronous
<ID3D11Counter
>(device
, query
, data_size
), desc(desc
)
710 virtual void STDMETHODCALLTYPE
GetDesc(
711 __out D3D11_COUNTER_DESC
*pDesc
)