192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri/**************************************************************************
292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * Copyright 2010 Luca Barbieri
492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * Permission is hereby granted, free of charge, to any person obtaining
692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * a copy of this software and associated documentation files (the
792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * "Software"), to deal in the Software without restriction, including
892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * without limitation the rights to use, copy, modify, merge, publish,
992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * distribute, sublicense, and/or sell copies of the Software, and to
1092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * permit persons to whom the Software is furnished to do so, subject to
1192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * the following conditions:
1292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
1392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * The above copyright notice and this permission notice (including the
1492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * next paragraph) shall be included in all copies or substantial
1592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * portions of the Software.
1692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
1792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
2192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
2592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri **************************************************************************/
2692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
2792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include "d3d1x_private.h"
2892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
2992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieriextern "C"
3092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri{
3192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include "util/u_gen_mipmap.h"
3292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include "tgsi/tgsi_ureg.h"
33f71f8c7d18a1a92681c337cb6dbf507ab06b62b1Luca Barbieri#include "tgsi/tgsi_dump.h"
3492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include "cso_cache/cso_context.h"
3592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri}
3692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
3792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
3892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri// the perl script will change this to 10 for d3d10, and also do s/D3D11/D3D10 in the whole file
3992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#define API 11
4092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
4192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#if API >= 11
4292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#define DX10_ONLY(x)
4392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#else
4492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#define DX10_ONLY(x) x
4592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#endif
4692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
4792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieritypedef D3D10_MAPPED_TEXTURE3D D3D10_MAPPED_SUBRESOURCE;
4892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
4992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri// used to make QueryInterface know the IIDs of the interface and its ancestors
5092617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11DeviceChild, IUnknown)
5192617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11InputLayout, ID3D11DeviceChild)
5292617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11DepthStencilState, ID3D11DeviceChild)
5392617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11BlendState, ID3D11DeviceChild)
5492617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11RasterizerState, ID3D11DeviceChild)
5592617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11SamplerState, ID3D11DeviceChild)
5692617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Resource, ID3D11DeviceChild)
5792617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Buffer, ID3D11Resource)
5892617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Texture1D, ID3D11Resource)
5992617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Texture2D, ID3D11Resource)
6092617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Texture3D, ID3D11Resource)
6192617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11View, ID3D11DeviceChild)
6292617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11ShaderResourceView, ID3D11View)
6392617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11RenderTargetView, ID3D11View)
6492617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11DepthStencilView, ID3D11View)
6592617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11VertexShader, ID3D11DeviceChild)
6692617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11GeometryShader, ID3D11DeviceChild)
6792617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11PixelShader, ID3D11DeviceChild)
6892617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Asynchronous, ID3D11DeviceChild)
6992617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Query, ID3D11Asynchronous)
7092617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Predicate, ID3D11Query)
7192617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Counter, ID3D11Asynchronous)
7292617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11Device, IUnknown)
7392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
7492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#if API >= 11
7592617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11UnorderedAccessView, ID3D11View)
7692617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11HullShader, ID3D11DeviceChild)
7792617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11DomainShader, ID3D11DeviceChild)
7892617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11ComputeShader, ID3D11DeviceChild)
7992617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11ClassInstance, ID3D11DeviceChild)
8092617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11ClassLinkage, ID3D11DeviceChild)
8192617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11CommandList, ID3D11DeviceChild)
8292617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D11DeviceContext, ID3D11DeviceChild)
8392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#else
8492617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D10BlendState1, ID3D10BlendState)
8592617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D10ShaderResourceView1, ID3D10ShaderResourceView)
8692617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriCOM_INTERFACE(ID3D10Device1, ID3D10Device)
8792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#endif
8892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
8992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieristruct GalliumD3D11Screen;
9092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
9192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#if API >= 11
9292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieristatic ID3D11DeviceContext* GalliumD3D11ImmediateDeviceContext_Create(GalliumD3D11Screen* device, struct pipe_context* pipe, bool owns_pipe);
9392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieristatic void GalliumD3D11ImmediateDeviceContext_RestoreGalliumState(ID3D11DeviceContext* context);
9492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieristatic void GalliumD3D11ImmediateDeviceContext_RestoreGalliumStateBlitOnly(ID3D11DeviceContext* context);
9592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieristatic void GalliumD3D11ImmediateDeviceContext_Destroy(ID3D11DeviceContext* device);
9692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#endif
9792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
9892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieristatic inline pipe_box d3d11_to_pipe_box(struct pipe_resource* resource, unsigned level, const D3D11_BOX* pBox)
9992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri{
10092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	pipe_box box;
10192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	if(pBox)
10292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	{
10392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.x = pBox->left;
10492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.y = pBox->top;
10592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.z = pBox->front;
10692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.width = pBox->right - pBox->left;
10792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.height = pBox->bottom - pBox->top;
10892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.depth = pBox->back - pBox->front;
10992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	}
11092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	else
11192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	{
11292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.x = box.y = box.z = 0;
11392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.width = u_minify(resource->width0, level);
11492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.height = u_minify(resource->height0, level);
11592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		box.depth = u_minify(resource->depth0, level);
11692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	}
11792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	return box;
11892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri}
11992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
12092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieristruct GalliumD3D11Caps
12192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri{
12292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	bool so;
12392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	bool gs;
12492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	bool queries;
12592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	bool render_condition;
12692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	unsigned constant_buffers[D3D11_STAGES];
12792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	unsigned stages;
128f1063cfee213ba92f7c9e34199caccf4bed78c1cLuca Barbieri	unsigned stages_with_sampling;
12992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri};
13092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
131b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieritypedef GalliumDXGIDevice<
132b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri	GalliumMultiComObject<
13392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#if API >= 11
134b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri		GalliumPrivateDataComObject<ID3D11Device>,
13592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#else
136b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri		GalliumPrivateDataComObject<ID3D10Device1>,
13792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#endif
138b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri		IGalliumDevice
13992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	>
140b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri> GalliumD3D11ScreenBase;
141b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri
142b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri// used to avoid needing to have forward declarations of functions
143b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri// this is called "screen" because in the D3D10 case it's only part of the device
144b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieristruct GalliumD3D11Screen : public GalliumD3D11ScreenBase
14592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri{
146b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri
14792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	pipe_screen* screen;
14892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	pipe_context* immediate_pipe;
14992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	GalliumD3D11Caps screen_caps;
15092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
15192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#if API >= 11
15292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	ID3D11DeviceContext* immediate_context;
15392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	ID3D11DeviceContext* get_immediate_context()
15492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	{
15592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		return immediate_context;
15692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	}
15792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#else
15892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	GalliumD3D11Screen* get_immediate_context()
15992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	{
16092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		return this;
16192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	}
16292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#endif
16392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
16492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
16592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	GalliumD3D11Screen(pipe_screen* screen, struct pipe_context* immediate_pipe, IDXGIAdapter* adapter)
166b4b2091655676ec3b898d3ae7298192aa7f9147fLuca Barbieri	: GalliumD3D11ScreenBase(adapter), screen(screen), immediate_pipe(immediate_pipe)
16792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	{
16892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	}
16992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
17092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#if API < 11
17192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	// we use a D3D11-like API internally
17292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual HRESULT STDMETHODCALLTYPE Map(
1738224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri			ID3D11Resource *pResource,
1748224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri			unsigned Subresource,
1758224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri			D3D11_MAP MapType,
1768224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri			unsigned MapFlags,
1778224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri			D3D11_MAPPED_SUBRESOURCE *pMappedResource) = 0;
17892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void STDMETHODCALLTYPE Unmap(
1798224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri			ID3D11Resource *pResource,
1808224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri			unsigned Subresource) = 0;
18192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void STDMETHODCALLTYPE Begin(
1828224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri		ID3D11Asynchronous *pAsync) = 0;
18392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void STDMETHODCALLTYPE End(
1848224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri		ID3D11Asynchronous *pAsync) = 0;
18592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual HRESULT STDMETHODCALLTYPE GetData(
1868224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri		ID3D11Asynchronous *pAsync,
1878224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri		void *pData,
1888224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri		unsigned DataSize,
1898224256946619fb25278718bbf4703e3b9d60c93Luca Barbieri		unsigned GetDataFlags) = 0;
19092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
19192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	// TODO: maybe we should use function overloading, but that might risk silent errors,
19292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	// and cannot be exported to a C interface
19392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindBlendState(ID3D11BlendState* state) = 0;
19492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindRasterizerState(ID3D11RasterizerState* state) = 0;
19592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindDepthStencilState(ID3D11DepthStencilState* state) = 0;
19692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindInputLayout(ID3D11InputLayout* state) = 0;
19792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindPixelShader(ID3D11PixelShader* state) = 0;
19892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindVertexShader(ID3D11VertexShader* state) = 0;
19992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindGeometryShader(ID3D11GeometryShader* state) = 0;
20092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindPredicate(ID3D11Predicate* predicate) = 0;
20192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindSamplerState(ID3D11SamplerState* state) = 0;
20292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindBuffer(ID3D11Buffer* buffer) = 0;
20392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindDepthStencilView(ID3D11DepthStencilView* view) = 0;
20492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindRenderTargetView(ID3D11RenderTargetView* view) = 0;
20592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	virtual void UnbindShaderResourceView(ID3D11ShaderResourceView* view) = 0;
20692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
20792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	void UnbindBlendState1(ID3D11BlendState1* state)
20892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	{
20992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		UnbindBlendState(state);
21092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	}
21192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	void UnbindShaderResourceView1(ID3D11ShaderResourceView1* view)
21292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	{
21392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		UnbindShaderResourceView(view);
21492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	}
21592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#endif
21692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri};
21792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
21892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include "d3d11_objects.h"
21992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include "d3d11_screen.h"
22092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include "d3d11_context.h"
22170fed0b0ec8a3ec4f6b9b47f1fe98cc54c6037f0Luca Barbieri#include "d3d11_misc.h"
22292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
22392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#if API >= 11
22492617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriHRESULT STDMETHODCALLTYPE GalliumD3D11DeviceCreate(struct pipe_screen* screen, struct pipe_context* context, BOOL owns_context, unsigned creation_flags, IDXGIAdapter* adapter, ID3D11Device** ppDevice)
22592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri{
22692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	if(creation_flags & D3D11_CREATE_DEVICE_SINGLETHREADED)
22792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		*ppDevice = new GalliumD3D11ScreenImpl<false>(screen, context, owns_context, creation_flags, adapter);
22892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	else
22992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		*ppDevice = new GalliumD3D11ScreenImpl<true>(screen, context, owns_context, creation_flags, adapter);
23092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	return S_OK;
23192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri}
23292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#else
23392617aeac109481258f0c3863d09c1b8903d438bLuca BarbieriHRESULT STDMETHODCALLTYPE GalliumD3D10DeviceCreate1(struct pipe_screen* screen, struct pipe_context* context, BOOL owns_context, unsigned creation_flags, IDXGIAdapter* adapter, ID3D10Device1** ppDevice)
23492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri{
23592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	if(creation_flags & D3D10_CREATE_DEVICE_SINGLETHREADED)
23692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		*ppDevice = new GalliumD3D10Device<false>(screen, context, owns_context, creation_flags, adapter);
23792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	else
23892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		*ppDevice = new GalliumD3D10Device<true>(screen, context, owns_context, creation_flags, adapter);
23992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	return S_OK;
24092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri}
24192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#endif
242