29 #include "GraphicsTypes.h" 30 #include "DXGITypeConversions.h" 35 inline UINT BindFlagsToD3D11BindFlags(Uint32 BindFlags)
37 UINT D3D11BindFlags = 0;
38 D3D11BindFlags = D3D11BindFlags | ((BindFlags &
BIND_VERTEX_BUFFER) ? D3D11_BIND_VERTEX_BUFFER : 0);
39 D3D11BindFlags = D3D11BindFlags | ((BindFlags &
BIND_INDEX_BUFFER) ? D3D11_BIND_INDEX_BUFFER : 0);
40 D3D11BindFlags = D3D11BindFlags | ((BindFlags &
BIND_UNIFORM_BUFFER) ? D3D11_BIND_CONSTANT_BUFFER : 0);
41 D3D11BindFlags = D3D11BindFlags | ((BindFlags &
BIND_SHADER_RESOURCE) ? D3D11_BIND_SHADER_RESOURCE : 0);
42 D3D11BindFlags = D3D11BindFlags | ((BindFlags &
BIND_STREAM_OUTPUT) ? D3D11_BIND_STREAM_OUTPUT : 0);
43 D3D11BindFlags = D3D11BindFlags | ((BindFlags &
BIND_RENDER_TARGET) ? D3D11_BIND_RENDER_TARGET : 0);
44 D3D11BindFlags = D3D11BindFlags | ((BindFlags &
BIND_DEPTH_STENCIL) ? D3D11_BIND_DEPTH_STENCIL : 0);
45 D3D11BindFlags = D3D11BindFlags | ((BindFlags &
BIND_UNORDERED_ACCESS) ? D3D11_BIND_UNORDERED_ACCESS : 0);
46 return D3D11BindFlags;
49 inline Uint32 D3D11BindFlagsToBindFlags(UINT D3D11BindFlags)
52 BindFlags = BindFlags | ((D3D11BindFlags & D3D11_BIND_VERTEX_BUFFER) ?
BIND_VERTEX_BUFFER : 0);
53 BindFlags = BindFlags | ((D3D11BindFlags & D3D11_BIND_INDEX_BUFFER) ?
BIND_INDEX_BUFFER : 0);
54 BindFlags = BindFlags | ((D3D11BindFlags & D3D11_BIND_CONSTANT_BUFFER) ?
BIND_UNIFORM_BUFFER : 0);
55 BindFlags = BindFlags | ((D3D11BindFlags & D3D11_BIND_SHADER_RESOURCE) ?
BIND_SHADER_RESOURCE : 0);
56 BindFlags = BindFlags | ((D3D11BindFlags & D3D11_BIND_STREAM_OUTPUT) ?
BIND_STREAM_OUTPUT : 0);
57 BindFlags = BindFlags | ((D3D11BindFlags & D3D11_BIND_RENDER_TARGET) ?
BIND_RENDER_TARGET : 0);
58 BindFlags = BindFlags | ((D3D11BindFlags & D3D11_BIND_DEPTH_STENCIL) ?
BIND_DEPTH_STENCIL : 0);
60 VERIFY_EXPR( (D3D11BindFlags &
61 (D3D11_BIND_VERTEX_BUFFER|D3D11_BIND_INDEX_BUFFER|D3D11_BIND_CONSTANT_BUFFER|
62 D3D11_BIND_SHADER_RESOURCE|D3D11_BIND_STREAM_OUTPUT|D3D11_BIND_RENDER_TARGET|
63 D3D11_BIND_DEPTH_STENCIL|D3D11_BIND_UNORDERED_ACCESS)) == BindFlagsToD3D11BindFlags(BindFlags));
69 inline D3D11_USAGE UsageToD3D11Usage(
USAGE Usage)
77 default: UNEXPECTED(
"Unknow usage" );
return D3D11_USAGE_DEFAULT;
81 inline USAGE D3D11UsageToUsage(D3D11_USAGE D3D11Usage)
89 default: UNEXPECTED(
"Unknow D3D11 usage" );
return USAGE_DEFAULT;
93 inline void MapParamsToD3D11MapParams(
MAP_TYPE MapType, Uint32 MapFlags, D3D11_MAP &d3d11MapType, UINT d3d11MapFlags)
95 d3d11MapType =
static_cast<D3D11_MAP
>(0);
99 d3d11MapType = D3D11_MAP_READ;
104 d3d11MapType = D3D11_MAP_WRITE_DISCARD;
106 d3d11MapType = D3D11_MAP_WRITE_NO_OVERWRITE;
108 d3d11MapType = D3D11_MAP_WRITE;
112 d3d11MapType = D3D11_MAP_READ_WRITE;
116 UNEXPECTED(
"Unknown map type" );
123 inline UINT MapFlagsToD3D11MapFlags(Uint32 MapFlags)
127 inline UINT CPUAccessFlagsToD3D11CPUAccessFlags(Uint32 Flags)
129 UINT D3D11CPUAccessFlags = 0;
130 D3D11CPUAccessFlags |= (Flags &
CPU_ACCESS_READ) ? D3D11_CPU_ACCESS_READ : 0;
131 D3D11CPUAccessFlags |= (Flags &
CPU_ACCESS_WRITE) ? D3D11_CPU_ACCESS_WRITE : 0;
132 return D3D11CPUAccessFlags;
135 inline Uint32 D3D11CPUAccessFlagsToCPUAccessFlags(UINT D3D11CPUAccessFlags)
137 Uint32 CPUAccessFlags = 0;
138 CPUAccessFlags |= (D3D11CPUAccessFlags & D3D11_CPU_ACCESS_READ) ?
CPU_ACCESS_READ : 0;
139 CPUAccessFlags |= (D3D11CPUAccessFlags & D3D11_CPU_ACCESS_WRITE) ?
CPU_ACCESS_WRITE : 0;
140 VERIFY_EXPR(D3D11CPUAccessFlags == CPUAccessFlagsToD3D11CPUAccessFlags(CPUAccessFlags));
141 return CPUAccessFlags;
144 inline UINT MiscTextureFlagsToD3D11Flags(Uint32 Flags)
146 UINT D3D11MiscFlags = 0;
148 return D3D11MiscFlags;
151 inline Uint32 D3D11MiscFlagsToMiscTextureFlags(UINT D3D11MiscFlags)
153 Uint32 MiscFlags = 0;
162 void DepthStencilStateDesc_To_D3D11_DEPTH_STENCIL_DESC(
const DepthStencilStateDesc &DepthStencilDesc, D3D11_DEPTH_STENCIL_DESC &d3d11DSSDesc);
163 void RasterizerStateDesc_To_D3D11_RASTERIZER_DESC(
const RasterizerStateDesc &RasterizerDesc, D3D11_RASTERIZER_DESC &d3d11RSDesc);
164 void BlendStateDesc_To_D3D11_BLEND_DESC(
const BlendStateDesc &BSDesc, D3D11_BLEND_DESC &D3D11BSDesc);
165 void LayoutElements_To_D3D11_INPUT_ELEMENT_DESCs(
const std::vector<LayoutElement, STDAllocatorRawMem<LayoutElement> > &LayoutElements,
166 std::vector<D3D11_INPUT_ELEMENT_DESC, STDAllocatorRawMem<D3D11_INPUT_ELEMENT_DESC> > &D3D11InputElements);
168 void TextureViewDesc_to_D3D11_SRV_DESC(
const TextureViewDesc& TexViewDesc, D3D11_SHADER_RESOURCE_VIEW_DESC &D3D11SRVDesc, Uint32 SampleCount);
169 void TextureViewDesc_to_D3D11_RTV_DESC(
const TextureViewDesc& TexViewDesc, D3D11_RENDER_TARGET_VIEW_DESC &D3D11RTVDesc, Uint32 SampleCount);
170 void TextureViewDesc_to_D3D11_DSV_DESC(
const TextureViewDesc& TexViewDesc, D3D11_DEPTH_STENCIL_VIEW_DESC &D3D11DSVDesc, Uint32 SampleCount);
171 void TextureViewDesc_to_D3D11_UAV_DESC(
const TextureViewDesc& TexViewDesc, D3D11_UNORDERED_ACCESS_VIEW_DESC &D3D11UAVDesc);
173 void BufferViewDesc_to_D3D11_SRV_DESC(
const BufferDesc &BuffDesc,
const BufferViewDesc& SRVDesc, D3D11_SHADER_RESOURCE_VIEW_DESC &D3D11SRVDesc);
174 void BufferViewDesc_to_D3D11_UAV_DESC(
const BufferDesc &BuffDesc,
const BufferViewDesc& UAVDesc, D3D11_UNORDERED_ACCESS_VIEW_DESC &D3D11UAVDesc);
A texture can be bound as a render target.
Definition: GraphicsTypes.h:71
PRIMITIVE_TOPOLOGY
Input primitive topology.
Definition: DeviceContext.h:56
A buffer or a texture can be bound as a shader resource.
Definition: GraphicsTypes.h:68
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
A buffer can be bound as an index buffer.
Definition: GraphicsTypes.h:65
TEXTURE_ADDRESS_MODE
Texture address mode.
Definition: GraphicsTypes.h:805
Previous contents of the resource will be undefined. This flag is only compatible with MAP_WRITE D3D...
Definition: GraphicsTypes.h:158
A buffer can be bound as a vertex buffer.
Definition: GraphicsTypes.h:64
A resource can be mapped for reading.
Definition: GraphicsTypes.h:114
A texture can be bound as a depth-stencil target.
Definition: GraphicsTypes.h:72
A resource that requires read and write access by the GPU and can also be occasionally written by the...
Definition: GraphicsTypes.h:95
The system will not synchronize pending operations before mapping the buffer. It is responsibility of...
Definition: GraphicsTypes.h:164
A resource that can only be read by the GPU. It cannot be written by the GPU, and cannot be accessed ...
Definition: GraphicsTypes.h:90
Specifies that map operation should not wait until previous command that using the same resource comp...
Definition: GraphicsTypes.h:153
Resource is mapped for writing. D3D11 counterpart: D3D11_MAP_WRITE. OpenGL counterpart: GL_MAP_WRIT...
Definition: GraphicsTypes.h:133
A resource that facilitates transferring data from GPU to CPU. D3D11 Counterpart: D3D11_USAGE_STAGI...
Definition: GraphicsTypes.h:103
Resource is mapped for reading. D3D11 counterpart: D3D11_MAP_READ. OpenGL counterpart: GL_MAP_READ_...
Definition: GraphicsTypes.h:129
USAGE
Resource usage.
Definition: GraphicsTypes.h:84
Allow automatic mipmap generation with ITextureView::GenerateMips()
Definition: GraphicsTypes.h:896
A buffer or a texture can be bound as an unordered access view.
Definition: GraphicsTypes.h:73
A buffer can be bound as a target for stream output stage.
Definition: GraphicsTypes.h:70
A buffer can be bound as a uniform buffer.
Definition: GraphicsTypes.h:66
FILTER_TYPE
Filter type.
Definition: GraphicsTypes.h:780
A resource can be mapped for writing.
Definition: GraphicsTypes.h:115
COMPARISON_FUNCTION
Comparison function.
Definition: GraphicsTypes.h:847
Resource is mapped for reading and writing. D3D11 counterpart: D3D11_MAP_READ_WRITE. OpenGL counterpart: GL_MAP_WRITE_BIT | GL_MAP_READ_BIT.
Definition: GraphicsTypes.h:137
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:125
A resource that can be read by the GPU and written at least once per frame by the CPU...
Definition: GraphicsTypes.h:99