mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphicsdriver/metal: Specify the texture type explicitly
This commit is contained in:
parent
a1abe6b728
commit
9f76b96c1f
@ -435,6 +435,7 @@ func (g *Graphics) genNextImageID() driver.ImageID {
|
||||
func (g *Graphics) NewImage(width, height int) (driver.Image, error) {
|
||||
g.checkSize(width, height)
|
||||
td := mtl.TextureDescriptor{
|
||||
TextureType: mtl.TextureType2D,
|
||||
PixelFormat: mtl.PixelFormatRGBA8UNorm,
|
||||
Width: graphics.InternalImageSize(width),
|
||||
Height: graphics.InternalImageSize(height),
|
||||
|
@ -150,6 +150,7 @@ fragment float4 FragmentShader(Vertex in [[stage_in]]) {
|
||||
|
||||
// Create an output texture to render into.
|
||||
td := mtl.TextureDescriptor{
|
||||
TextureType: mtl.TextureType2D,
|
||||
PixelFormat: mtl.PixelFormatRGBA8UNorm,
|
||||
Width: 80,
|
||||
Height: 20,
|
||||
|
@ -87,6 +87,16 @@ const (
|
||||
FeatureSet_macOS_ReadWriteTextureTier2 FeatureSet = 10002
|
||||
)
|
||||
|
||||
// TextureType defines The dimension of each image, including whether multiple images are arranged into an array or
|
||||
// a cube.
|
||||
//
|
||||
// Reference: https://developer.apple.com/documentation/metal/mtltexturetype
|
||||
type TextureType uint16
|
||||
|
||||
const (
|
||||
TextureType2D TextureType = 2
|
||||
)
|
||||
|
||||
// PixelFormat defines data formats that describe the organization
|
||||
// and characteristics of individual pixels in a texture.
|
||||
//
|
||||
@ -362,6 +372,7 @@ type ClearColor struct {
|
||||
//
|
||||
// Reference: https://developer.apple.com/documentation/metal/mtltexturedescriptor.
|
||||
type TextureDescriptor struct {
|
||||
TextureType TextureType
|
||||
PixelFormat PixelFormat
|
||||
Width int
|
||||
Height int
|
||||
@ -481,6 +492,7 @@ func (d Device) MakeBufferWithLength(length uintptr, opt ResourceOptions) Buffer
|
||||
// Reference: https://developer.apple.com/documentation/metal/mtldevice/1433425-maketexture.
|
||||
func (d Device) MakeTexture(td TextureDescriptor) Texture {
|
||||
descriptor := C.struct_TextureDescriptor{
|
||||
TextureType: C.uint16_t(td.TextureType),
|
||||
PixelFormat: C.uint16_t(td.PixelFormat),
|
||||
Width: C.uint_t(td.Width),
|
||||
Height: C.uint_t(td.Height),
|
||||
|
@ -69,6 +69,7 @@ struct RenderPassDescriptor {
|
||||
};
|
||||
|
||||
struct TextureDescriptor {
|
||||
uint16_t TextureType;
|
||||
uint16_t PixelFormat;
|
||||
uint_t Width;
|
||||
uint_t Height;
|
||||
|
@ -113,6 +113,7 @@ void *Device_MakeBufferWithLength(void *device, size_t length,
|
||||
|
||||
void *Device_MakeTexture(void *device, struct TextureDescriptor descriptor) {
|
||||
MTLTextureDescriptor *textureDescriptor = [[MTLTextureDescriptor alloc] init];
|
||||
textureDescriptor.textureType = descriptor.TextureType;
|
||||
textureDescriptor.pixelFormat = descriptor.PixelFormat;
|
||||
textureDescriptor.width = descriptor.Width;
|
||||
textureDescriptor.height = descriptor.Height;
|
||||
|
@ -93,6 +93,7 @@ fragment float4 FragmentShader(Vertex in [[stage_in]]) {
|
||||
|
||||
// Create an output texture to render into.
|
||||
td := mtl.TextureDescriptor{
|
||||
TextureType: mtl.TextureType2D,
|
||||
PixelFormat: mtl.PixelFormatRGBA8UNorm,
|
||||
Width: 512,
|
||||
Height: 512,
|
||||
|
Loading…
Reference in New Issue
Block a user