zorldo

Goofing around with Ebiten
git clone git://bsandro.tech/zorldo
Log | Files | Refs | README

mtl_darwin.h (7886B)


      1 // Copyright 2018 The Ebiten Authors
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #include <stddef.h>
     16 #include <stdint.h>
     17 
     18 typedef unsigned long uint_t;
     19 
     20 struct Device {
     21   void *Device;
     22   uint8_t Headless;
     23   uint8_t LowPower;
     24   uint8_t Removable;
     25   uint64_t RegistryID;
     26   const char *Name;
     27 };
     28 
     29 struct Devices {
     30   struct Device *Devices;
     31   int Length;
     32 };
     33 
     34 struct Library {
     35   void *Library;
     36   const char *Error;
     37 };
     38 
     39 struct RenderPipelineDescriptor {
     40   void *VertexFunction;
     41   void *FragmentFunction;
     42   uint16_t ColorAttachment0PixelFormat;
     43   uint8_t ColorAttachment0BlendingEnabled;
     44   uint8_t ColorAttachment0DestinationAlphaBlendFactor;
     45   uint8_t ColorAttachment0DestinationRGBBlendFactor;
     46   uint8_t ColorAttachment0SourceAlphaBlendFactor;
     47   uint8_t ColorAttachment0SourceRGBBlendFactor;
     48   uint8_t ColorAttachment0WriteMask;
     49   uint8_t StencilAttachmentPixelFormat;
     50 };
     51 
     52 struct RenderPipelineState {
     53   void *RenderPipelineState;
     54   const char *Error;
     55 };
     56 
     57 struct ClearColor {
     58   double Red;
     59   double Green;
     60   double Blue;
     61   double Alpha;
     62 };
     63 
     64 struct RenderPassDescriptor {
     65   uint8_t ColorAttachment0LoadAction;
     66   uint8_t ColorAttachment0StoreAction;
     67   struct ClearColor ColorAttachment0ClearColor;
     68   void *ColorAttachment0Texture;
     69   uint8_t StencilAttachmentLoadAction;
     70   uint8_t StencilAttachmentStoreAction;
     71   void *StencilAttachmentTexture;
     72 };
     73 
     74 struct TextureDescriptor {
     75   uint16_t TextureType;
     76   uint16_t PixelFormat;
     77   uint_t Width;
     78   uint_t Height;
     79   uint8_t StorageMode;
     80   uint8_t Usage;
     81 };
     82 
     83 struct Origin {
     84   uint_t X;
     85   uint_t Y;
     86   uint_t Z;
     87 };
     88 
     89 struct Size {
     90   uint_t Width;
     91   uint_t Height;
     92   uint_t Depth;
     93 };
     94 
     95 struct Region {
     96   struct Origin Origin;
     97   struct Size Size;
     98 };
     99 
    100 struct Viewport {
    101   double OriginX;
    102   double OriginY;
    103   double Width;
    104   double Height;
    105   double ZNear;
    106   double ZFar;
    107 };
    108 
    109 struct ScissorRect {
    110   uint_t X;
    111   uint_t Y;
    112   uint_t Width;
    113   uint_t Height;
    114 };
    115 
    116 struct DepthStencilDescriptor {
    117   uint8_t BackFaceStencilStencilFailureOperation;
    118   uint8_t BackFaceStencilDepthFailureOperation;
    119   uint8_t BackFaceStencilDepthStencilPassOperation;
    120   uint8_t BackFaceStencilStencilCompareFunction;
    121   uint8_t FrontFaceStencilStencilFailureOperation;
    122   uint8_t FrontFaceStencilDepthFailureOperation;
    123   uint8_t FrontFaceStencilDepthStencilPassOperation;
    124   uint8_t FrontFaceStencilStencilCompareFunction;
    125 };
    126 
    127 struct Device CreateSystemDefaultDevice();
    128 struct Devices CopyAllDevices();
    129 
    130 uint8_t Device_SupportsFeatureSet(void *device, uint16_t featureSet);
    131 void *Device_MakeCommandQueue(void *device);
    132 struct Library Device_MakeLibrary(void *device, const char *source,
    133                                   size_t sourceLength);
    134 struct RenderPipelineState
    135 Device_MakeRenderPipelineState(void *device,
    136                                struct RenderPipelineDescriptor descriptor);
    137 void *Device_MakeBufferWithBytes(void *device, const void *bytes, size_t length,
    138                                  uint16_t options);
    139 void *Device_MakeBufferWithLength(void *device, size_t length,
    140                                   uint16_t options);
    141 void *Device_MakeTexture(void *device, struct TextureDescriptor descriptor);
    142 void *Device_MakeDepthStencilState(void *device,
    143                                    struct DepthStencilDescriptor descriptor);
    144 
    145 void CommandQueue_Release(void *commandQueue);
    146 void *CommandQueue_MakeCommandBuffer(void *commandQueue);
    147 
    148 void CommandBuffer_Retain(void *commandBuffer);
    149 void CommandBuffer_Release(void *commandBuffer);
    150 uint8_t CommandBuffer_Status(void *commandBuffer);
    151 void CommandBuffer_PresentDrawable(void *commandBuffer, void *drawable);
    152 void CommandBuffer_Commit(void *commandBuffer);
    153 void CommandBuffer_WaitUntilCompleted(void *commandBuffer);
    154 void CommandBuffer_WaitUntilScheduled(void *commandBuffer);
    155 void *
    156 CommandBuffer_MakeRenderCommandEncoder(void *commandBuffer,
    157                                        struct RenderPassDescriptor descriptor);
    158 void *CommandBuffer_MakeBlitCommandEncoder(void *commandBuffer);
    159 
    160 void CommandEncoder_EndEncoding(void *commandEncoder);
    161 
    162 void RenderCommandEncoder_Release(void *renderCommandEncoder);
    163 void RenderCommandEncoder_SetRenderPipelineState(void *renderCommandEncoder,
    164                                                  void *renderPipelineState);
    165 void RenderCommandEncoder_SetViewport(void *renderCommandEncoder,
    166                                       struct Viewport viewport);
    167 void RenderCommandEncoder_SetScissorRect(void *renderCommandEncoder,
    168                                          struct ScissorRect scissorRect);
    169 void RenderCommandEncoder_SetVertexBuffer(void *renderCommandEncoder,
    170                                           void *buffer, uint_t offset,
    171                                           uint_t index);
    172 void RenderCommandEncoder_SetVertexBytes(void *renderCommandEncoder,
    173                                          const void *bytes, size_t length,
    174                                          uint_t index);
    175 void RenderCommandEncoder_SetFragmentBytes(void *renderCommandEncoder,
    176                                            const void *bytes, size_t length,
    177                                            uint_t index);
    178 void RenderCommandEncoder_SetBlendColor(void *renderCommandEncoder, float red,
    179                                         float green, float blue, float alpha);
    180 void RenderCommandEncoder_SetFragmentTexture(void *renderCommandEncoder,
    181                                              void *texture, uint_t index);
    182 void RenderCommandEncoder_SetDepthStencilState(void *renderCommandEncoder,
    183                                                void *depthStencilState);
    184 void RenderCommandEncoder_DrawPrimitives(void *renderCommandEncoder,
    185                                          uint8_t primitiveType,
    186                                          uint_t vertexStart,
    187                                          uint_t vertexCount);
    188 void RenderCommandEncoder_DrawIndexedPrimitives(
    189     void *renderCommandEncoder, uint8_t primitiveType, uint_t indexCount,
    190     uint8_t indexType, void *indexBuffer, uint_t indexBufferOffset);
    191 
    192 void BlitCommandEncoder_Synchronize(void *blitCommandEncoder, void *resource);
    193 void BlitCommandEncoder_SynchronizeTexture(void *blitCommandEncoder,
    194                                            void *texture, uint_t slice,
    195                                            uint_t level);
    196 void BlitCommandEncoder_CopyFromTexture(
    197     void *blitCommandEncoder, void *sourceTexture, uint_t sourceSlice,
    198     uint_t sourceLevel, struct Origin sourceOrigin, struct Size sourceSize,
    199     void *destinationTexture, uint_t destinationSlice, uint_t destinationLevel,
    200     struct Origin destinationOrigin);
    201 
    202 void *Library_MakeFunction(void *library, const char *name);
    203 
    204 void Texture_Release(void *texture);
    205 void Texture_GetBytes(void *texture, void *pixelBytes, size_t bytesPerRow,
    206                       struct Region region, uint_t level);
    207 void Texture_ReplaceRegion(void *texture, struct Region region, uint_t level,
    208                            void *pixelBytes, uint_t bytesPerRow);
    209 int Texture_Width(void *texture);
    210 int Texture_Height(void *texture);
    211 
    212 size_t Buffer_Length(void *buffer);
    213 void Buffer_CopyToContents(void *buffer, void *data, size_t lengthInBytes);
    214 void Buffer_Retain(void *buffer);
    215 void Buffer_Release(void *buffer);
    216 void Function_Release(void *function);
    217 void RenderPipelineState_Release(void *renderPipelineState);
    218 void DepthStencilState_Release(void *depthStencilState);