ebiten/internal/graphicsdriver/metal/mtl/mtl.h
2018-12-20 02:37:10 +09:00

176 lines
5.7 KiB
C

// Copyright 2018 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build darwin
#include <stddef.h>
typedef signed char BOOL;
typedef unsigned long uint_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long long uint64_t;
struct Device {
void *Device;
BOOL Headless;
BOOL LowPower;
BOOL Removable;
uint64_t RegistryID;
const char *Name;
};
struct Devices {
struct Device *Devices;
int Length;
};
struct Library {
void *Library;
const char *Error;
};
struct RenderPipelineDescriptor {
void *VertexFunction;
void *FragmentFunction;
uint16_t ColorAttachment0PixelFormat;
BOOL ColorAttachment0BlendingEnabled;
uint8_t ColorAttachment0DestinationAlphaBlendFactor;
uint8_t ColorAttachment0DestinationRGBBlendFactor;
uint8_t ColorAttachment0SourceAlphaBlendFactor;
uint8_t ColorAttachment0SourceRGBBlendFactor;
};
struct RenderPipelineState {
void *RenderPipelineState;
const char *Error;
};
struct ClearColor {
double Red;
double Green;
double Blue;
double Alpha;
};
struct RenderPassDescriptor {
uint8_t ColorAttachment0LoadAction;
uint8_t ColorAttachment0StoreAction;
struct ClearColor ColorAttachment0ClearColor;
void *ColorAttachment0Texture;
};
struct TextureDescriptor {
uint16_t PixelFormat;
uint_t Width;
uint_t Height;
uint8_t StorageMode;
uint8_t Usage;
};
struct Origin {
uint_t X;
uint_t Y;
uint_t Z;
};
struct Size {
uint_t Width;
uint_t Height;
uint_t Depth;
};
struct Region {
struct Origin Origin;
struct Size Size;
};
struct Viewport {
double OriginX;
double OriginY;
double Width;
double Height;
double ZNear;
double ZFar;
};
struct Device CreateSystemDefaultDevice();
struct Devices CopyAllDevices();
BOOL Device_SupportsFeatureSet(void *device, uint16_t featureSet);
void *Device_MakeCommandQueue(void *device);
struct Library Device_MakeLibrary(void *device, const char *source,
size_t sourceLength);
struct RenderPipelineState
Device_MakeRenderPipelineState(void *device,
struct RenderPipelineDescriptor descriptor);
void *Device_MakeBuffer(void *device, const void *bytes, size_t length,
uint16_t options);
void *Device_MakeTexture(void *device, struct TextureDescriptor descriptor);
void CommandQueue_Release(void *commandQueue);
void *CommandQueue_MakeCommandBuffer(void *commandQueue);
void CommandBuffer_Release(void *commandBuffer);
void CommandBuffer_PresentDrawable(void *commandBuffer, void *drawable);
void CommandBuffer_Commit(void *commandBuffer);
void CommandBuffer_WaitUntilCompleted(void *commandBuffer);
void *
CommandBuffer_MakeRenderCommandEncoder(void *commandBuffer,
struct RenderPassDescriptor descriptor);
void *CommandBuffer_MakeBlitCommandEncoder(void *commandBuffer);
void CommandEncoder_EndEncoding(void *commandEncoder);
void RenderCommandEncoder_Release(void *renderCommandEncoder);
void RenderCommandEncoder_SetRenderPipelineState(void *renderCommandEncoder,
void *renderPipelineState);
void RenderCommandEncoder_SetViewport(void *renderCommandEncoder,
struct Viewport viewport);
void RenderCommandEncoder_SetVertexBuffer(void *renderCommandEncoder,
void *buffer, uint_t offset,
uint_t index);
void RenderCommandEncoder_SetVertexBytes(void *renderCommandEncoder,
const void *bytes, size_t length,
uint_t index);
void RenderCommandEncoder_SetFragmentBytes(void *renderCommandEncoder,
const void *bytes, size_t length,
uint_t index);
void RenderCommandEncoder_SetBlendColor(void *renderCommandEncoder, float red,
float green, float blue, float alpha);
void RenderCommandEncoder_SetFragmentTexture(void *renderCommandEncoder,
void *texture, uint_t index);
void RenderCommandEncoder_DrawPrimitives(void *renderCommandEncoder,
uint8_t primitiveType,
uint_t vertexStart,
uint_t vertexCount);
void RenderCommandEncoder_DrawIndexedPrimitives(
void *renderCommandEncoder, uint8_t primitiveType, uint_t indexCount,
uint8_t indexType, void *indexBuffer, uint_t indexBufferOffset);
void BlitCommandEncoder_Synchronize(void *blitCommandEncoder, void *resource);
void BlitCommandEncoder_SynchronizeTexture(void *blitCommandEncoder,
void *texture, uint_t slice,
uint_t level);
void *Library_MakeFunction(void *library, const char *name);
void Texture_Release(void *texture);
void Texture_GetBytes(void *texture, void *pixelBytes, size_t bytesPerRow,
struct Region region, uint_t level);
void Texture_ReplaceRegion(void *texture, struct Region region, uint_t level,
void *pixelBytes, uint_t bytesPerRow);
void Buffer_Release(void *buffer);