3using SharpDX.Direct3D11;
6using Silk.NET.OpenGLES;
7using System.Runtime.InteropServices;
31 ArgumentNullException.ThrowIfNull(value);
33 value.IsLocked =
true;
40 ArgumentNullException.ThrowIfNull(value);
42 value.IsLocked =
true;
49 ArgumentNullException.ThrowIfNull(value);
51 value.IsLocked =
true;
76 (resource as
Shader)?.CompileShaders();
103 int verticesCount) where T : unmanaged {
104 VerifyParametersDrawUser(primitiveType, shader, vertexDeclaration, vertexData, startVertex, verticesCount);
106 int num =
DXWrapper.AppendUserVertices(vertexData, vertexDeclaration.VertexStride, startVertex, verticesCount);
117 GCHandle gCHandle = GCHandle.Alloc(vertexData, GCHandleType.Pinned);
124 gCHandle.AddrOfPinnedObject() + startVertex * vertexDeclaration.VertexStride,
147 int indicesCount) where T : unmanaged {
148 VerifyParametersDrawUserIndexed(
160 int num =
DXWrapper.AppendUserVertices(vertexData, vertexDeclaration.VertexStride, startVertex, verticesCount);
173 GCHandle gCHandle = GCHandle.Alloc(vertexData, GCHandleType.Pinned);
174 GCHandle gCHandle2 = GCHandle.Alloc(indexData, GCHandleType.Pinned);
185 DrawElementsType.UnsignedInt,
186 (gCHandle2.AddrOfPinnedObject() + 4 * startIndex).ToPointer()
249 new IntPtr(startIndex * indexBuffer.
IndexFormat.GetSize()).ToPointer()
255 public static void Clear(
Vector4? color,
float? depth =
null,
int? stencil =
null) {
262 new Color4(color.Value.
X, color.Value.
Y, color.Value.
Z, color.Value.
W)
268 new Color4(color.Value.
X, color.Value.
Y, color.Value.
Z, color.Value.
W)
273 || stencil !=
null) {
276 DepthStencilClearFlags depthStencilClearFlags = 0;
278 depthStencilClearFlags |= DepthStencilClearFlags.Depth;
281 if (stencil !=
null) {
282 depthStencilClearFlags |= DepthStencilClearFlags.Stencil;
283 b = (byte)stencil.Value;
343 public static void Clear(
Color? color,
float? depth =
null,
int? stencil =
null) {
352 int verticesCount) where T : unmanaged {
354 ArgumentNullException.ThrowIfNull(shader);
355 ArgumentNullException.ThrowIfNull(vertexDeclaration);
356 ArgumentNullException.ThrowIfNull(vertexData);
357 if (vertexDeclaration.VertexStride / num * num != vertexDeclaration.VertexStride) {
358 throw new InvalidOperationException(
359 $
"Vertex is not an integer multiple of array element, vertex stride is {vertexDeclaration.VertexStride}, array element is {num}."
364 || startVertex + verticesCount > vertexData.Length) {
365 throw new ArgumentException(
"Vertices range is out of bounds.");
367 shader.VerifyNotDisposed();
378 int indicesCount) where T : unmanaged {
380 ArgumentNullException.ThrowIfNull(shader);
381 ArgumentNullException.ThrowIfNull(vertexDeclaration);
382 ArgumentNullException.ThrowIfNull(vertexData);
383 ArgumentNullException.ThrowIfNull(indexData);
384 if (vertexDeclaration.VertexStride / num * num != vertexDeclaration.VertexStride) {
385 throw new InvalidOperationException(
386 $
"Vertex is not an integer multiple of array element, vertex stride is {vertexDeclaration.VertexStride}, array element is {num}."
391 || startVertex + verticesCount > vertexData.Length) {
392 throw new ArgumentException(
"Vertices range is out of bounds.");
396 || startIndex + indicesCount > indexData.Length) {
397 throw new ArgumentException(
"Indices range is out of bounds.");
399 shader.VerifyNotDisposed();
408 ArgumentNullException.ThrowIfNull(shader);
409 ArgumentNullException.ThrowIfNull(vertexBuffer);
412 || startVertex + verticesCount > vertexBuffer.
VerticesCount) {
413 throw new ArgumentException(
"Vertices range is out of bounds.");
424 ArgumentNullException.ThrowIfNull(shader);
425 ArgumentNullException.ThrowIfNull(vertexBuffer);
426 ArgumentNullException.ThrowIfNull(indexBuffer);
429 || startIndex + indicesCount > indexBuffer.
IndicesCount) {
430 throw new ArgumentException(
"Indices range is out of bounds.");
static DepthStencilView DepthBufferView
static bool ResizeSwapChainIfNeeded()
static void ApplyRasterizerState(RasterizerState rasterizerState)
static void ApplyVertexBuffer(SharpDX.Direct3D11.Buffer vertexBuffer, int vertexStride, int vertexOffset)
static void ApplyViewportScissor(Viewport viewport, Rectangle scissorRectangle)
static void DisposeDevice()
static DeviceContext2 Context
static void ApplyBlendState(BlendState blendState)
static void ApplyShaderAndRenderTarget(RenderTarget2D renderTarget, Shader shader, VertexDeclaration vertexDeclaration)
static void CreateDevice()
static SharpDX.Direct3D11.Buffer UserIndexBuffer
static int REQ_TEXTURE2D_U_OR_V_DIMENSION
static void ApplyIndexBuffer(SharpDX.Direct3D11.Buffer indexBuffer, Format format, int indexOffset)
static int AppendUserIndices(int[] indices, int indexStride, int startIndex, int indicesCount)
static void ApplyDepthStencilState(DepthStencilState depthStencilState)
static RenderTargetView ColorBufferView
static SharpDX.Direct3D11.Buffer UserVertexBuffer
static Format TranslateIndexFormat(IndexFormat indexFormat)
static void ApplyPrimitiveType(PrimitiveType primitiveType)
static int MaxTextureSize
static Action DeviceReset
static void Clear(Vector4? color, float? depth=null, int? stencil=null)
static DepthStencilState m_depthStencilState
static BlendState BlendState
static void VerifyParametersDrawUserIndexed< T >(PrimitiveType primitiveType, Shader shader, VertexDeclaration vertexDeclaration, T[] vertexData, int startVertex, int verticesCount, int[] indexData, int startIndex, int indicesCount)
static Rectangle ScissorRectangle
static void Draw(PrimitiveType primitiveType, Shader shader, VertexBuffer vertexBuffer, int startVertex, int verticesCount)
static RenderTarget2D m_renderTarget
static void VerifyParametersDrawUser< T >(PrimitiveType primitiveType, Shader shader, VertexDeclaration vertexDeclaration, T[] vertexData, int startVertex, int verticesCount)
static bool UseReducedZRange
static BlendState m_blendState
static DepthStencilState DepthStencilState
static bool m_useReducedZRange
static void VerifyParametersDraw(PrimitiveType primitiveType, Shader shader, VertexBuffer vertexBuffer, int startVertex, int verticesCount)
static void Clear(Color? color, float? depth=null, int? stencil=null)
static void HandleDeviceLost()
static void HandleDeviceReset()
static string DeviceDescription
static void DrawUserIndexed< T >(PrimitiveType primitiveType, Shader shader, VertexDeclaration vertexDeclaration, T[] vertexData, int startVertex, int verticesCount, int[] indexData, int startIndex, int indicesCount)
static Point2 BackbufferSize
static void ResetGLStateCache()
static long GetGpuMemoryUsage()
static void BeforeFrame()
static RasterizerState m_rasterizerState
static void DrawIndexed(PrimitiveType primitiveType, Shader shader, VertexBuffer vertexBuffer, IndexBuffer indexBuffer, int startIndex, int indicesCount)
static RenderTarget2D RenderTarget
static void VerifyParametersDrawIndexed(PrimitiveType primitiveType, Shader shader, VertexBuffer vertexBuffer, IndexBuffer indexBuffer, int startIndex, int indicesCount)
static RasterizerState RasterizerState
static void DrawUser< T >(PrimitiveType primitiveType, Shader shader, VertexDeclaration vertexDeclaration, T[] vertexData, int startVertex, int verticesCount)
static int GL_MAX_TEXTURE_SIZE
static void ApplyDepthStencilState(DepthStencilState state)
static void ApplyRasterizerState(RasterizerState state)
static void Clear(RenderTarget2D renderTarget, Vector4? color, float? depth, int? stencil)
static void ApplyViewportScissor(Viewport viewport, Rectangle scissorRectangle, bool isScissorEnabled)
static void ApplyBlendState(BlendState state)
static Silk.NET.OpenGLES.PrimitiveType TranslatePrimitiveType(PrimitiveType primitiveType)
static void InitializeCache()
static unsafe void ApplyShaderAndBuffers(Shader shader, VertexDeclaration vertexDeclaration, IntPtr vertexOffset, int arrayBuffer, int? elementArrayBuffer)
static DrawElementsType TranslateIndexFormat(IndexFormat indexFormat)
static void ApplyRenderTarget(RenderTarget2D renderTarget)
static HashSet< GraphicsResource > m_resources
VertexDeclaration VertexDeclaration