Added external texture parameter. (#3596)

* Added external texture parameter.

* Use uint64_t instead of uintptr_t for external texture because VkImage is always 64-bit.
This commit is contained in:
Branimir Karadžić
2026-02-18 12:12:37 -08:00
committed by GitHub
parent 02e04fb458
commit 40e614c45d
24 changed files with 762 additions and 426 deletions

View File

@@ -739,6 +739,11 @@ public static class bgfx
/// </summary>
ReadBack = 0x0000800000000000,
/// <summary>
/// Texture is shared with other device or other process.
/// </summary>
ExternalShared = 0x0001000000000000,
/// <summary>
/// Render target MSAAx2 mode.
/// </summary>
@@ -1122,50 +1127,60 @@ public static class bgfx
/// </summary>
TextureDirectAccess = 0x0000000000400000,
/// <summary>
/// External texture is supported.
/// </summary>
TextureExternal = 0x0000000000800000,
/// <summary>
/// External shared texture is supported.
/// </summary>
TextureExternalShared = 0x0000000001000000,
/// <summary>
/// Read-back texture is supported.
/// </summary>
TextureReadBack = 0x0000000000800000,
TextureReadBack = 0x0000000002000000,
/// <summary>
/// 2D texture array is supported.
/// </summary>
Texture2dArray = 0x0000000001000000,
Texture2dArray = 0x0000000004000000,
/// <summary>
/// 3D textures are supported.
/// </summary>
Texture3d = 0x0000000002000000,
Texture3d = 0x0000000008000000,
/// <summary>
/// Transparent back buffer supported.
/// </summary>
TransparentBackbuffer = 0x0000000004000000,
TransparentBackbuffer = 0x0000000010000000,
/// <summary>
/// Variable Rate Shading
/// </summary>
VariableRateShading = 0x0000000008000000,
VariableRateShading = 0x0000000020000000,
/// <summary>
/// Vertex attribute half-float is supported.
/// </summary>
VertexAttribHalf = 0x0000000010000000,
VertexAttribHalf = 0x0000000040000000,
/// <summary>
/// Vertex attribute 10_10_10_2 is supported.
/// </summary>
VertexAttribUint10 = 0x0000000020000000,
VertexAttribUint10 = 0x0000000080000000,
/// <summary>
/// Rendering with VertexID only is supported.
/// </summary>
VertexId = 0x0000000040000000,
VertexId = 0x0000000100000000,
/// <summary>
/// Viewport layer is available in vertex shader.
/// </summary>
ViewportLayerArray = 0x0000000080000000,
ViewportLayerArray = 0x0000000200000000,
/// <summary>
/// All texture compare modes are supported.
@@ -2205,6 +2220,7 @@ public static class bgfx
public void* ndt;
public void* nwh;
public void* context;
public void* queue;
public void* backBuffer;
public void* backBufferDS;
public NativeWindowHandleType type;
@@ -3234,9 +3250,10 @@ public static class bgfx
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
/// <param name="_external">Native API pointer to texture.</param>
///
[LinkName("bgfx_create_texture_2d")]
public static extern TextureHandle create_texture_2d(uint16 _width, uint16 _height, bool _hasMips, uint16 _numLayers, TextureFormat _format, uint64 _flags, Memory* _mem);
public static extern TextureHandle create_texture_2d(uint16 _width, uint16 _height, bool _hasMips, uint16 _numLayers, TextureFormat _format, uint64 _flags, Memory* _mem, uint64 _external);
/// <summary>
/// Create texture with size based on back-buffer ratio. Texture will maintain ratio
@@ -3263,9 +3280,10 @@ public static class bgfx
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
/// <param name="_external">Native API pointer to texture.</param>
///
[LinkName("bgfx_create_texture_3d")]
public static extern TextureHandle create_texture_3d(uint16 _width, uint16 _height, uint16 _depth, bool _hasMips, TextureFormat _format, uint64 _flags, Memory* _mem);
public static extern TextureHandle create_texture_3d(uint16 _width, uint16 _height, uint16 _depth, bool _hasMips, TextureFormat _format, uint64 _flags, Memory* _mem, uint64 _external);
/// <summary>
/// Create Cube texture.
@@ -3276,10 +3294,11 @@ public static class bgfx
/// <param name="_numLayers">Number of layers in texture array. Must be 1 if caps `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.</param>
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than</param>
/// <param name="_external">Native API pointer to texture.</param>
///
[LinkName("bgfx_create_texture_cube")]
public static extern TextureHandle create_texture_cube(uint16 _size, bool _hasMips, uint16 _numLayers, TextureFormat _format, uint64 _flags, Memory* _mem);
public static extern TextureHandle create_texture_cube(uint16 _size, bool _hasMips, uint16 _numLayers, TextureFormat _format, uint64 _flags, Memory* _mem, uint64 _external);
/// <summary>
/// Update 2D texture.

View File

@@ -465,6 +465,9 @@ enum TextureFlags : const ulong
// Texture will be used for read back from GPU.
READBACK = 0x0000800000000000,
// Texture is shared with other device or other process.
EXTERNALSHARED = 0x0001000000000000,
// Render target MSAAx2 mode.
RTMSAAX2 = 0x0000002000000000,
@@ -711,32 +714,38 @@ enum CapsFlags : const ulong
// CPU direct access to GPU texture memory.
TEXTUREDIRECTACCESS = 0x0000000000400000,
// External texture is supported.
TEXTUREEXTERNAL = 0x0000000000800000,
// External shared texture is supported.
TEXTUREEXTERNALSHARED = 0x0000000001000000,
// Read-back texture is supported.
TEXTUREREADBACK = 0x0000000000800000,
TEXTUREREADBACK = 0x0000000002000000,
// 2D texture array is supported.
TEXTURE_2DARRAY = 0x0000000001000000,
TEXTURE_2DARRAY = 0x0000000004000000,
// 3D textures are supported.
TEXTURE_3D = 0x0000000002000000,
TEXTURE_3D = 0x0000000008000000,
// Transparent back buffer supported.
TRANSPARENTBACKBUFFER = 0x0000000004000000,
TRANSPARENTBACKBUFFER = 0x0000000010000000,
// Variable Rate Shading
VARIABLERATESHADING = 0x0000000008000000,
VARIABLERATESHADING = 0x0000000020000000,
// Vertex attribute half-float is supported.
VERTEXATTRIBHALF = 0x0000000010000000,
VERTEXATTRIBHALF = 0x0000000040000000,
// Vertex attribute 10_10_10_2 is supported.
VERTEXATTRIBUINT10 = 0x0000000020000000,
VERTEXATTRIBUINT10 = 0x0000000080000000,
// Rendering with VertexID only is supported.
VERTEXID = 0x0000000040000000,
VERTEXID = 0x0000000100000000,
// Viewport layer is available in vertex shader.
VIEWPORTLAYERARRAY = 0x0000000080000000,
VIEWPORTLAYERARRAY = 0x0000000200000000,
// All texture compare modes are supported.
TEXTURECOMPAREALL = 0x0000000000180000,
@@ -1512,6 +1521,8 @@ struct PlatformData
// GL context, D3D device, or Vulkan device. If `NULL`, bgfx
// will create context/device.
void* context;
// D3D12 Queue. If `NULL` bgfx will create queue.
void* queue;
// GL back-buffer, or D3D render target view. If `NULL` bgfx will
// create back-buffer color surface.
void* backBuffer;
@@ -2321,7 +2332,8 @@ extern fn TextureHandle create_texture(Memory* _mem, ulong _flags, char _skip, T
// _format : `Texture format. See: `TextureFormat::Enum`.`
// _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
// _mem : `Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.`
extern fn TextureHandle create_texture_2d(ushort _width, ushort _height, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem) @extern("bgfx_create_texture_2d");
// _external : `Native API pointer to texture.`
extern fn TextureHandle create_texture_2d(ushort _width, ushort _height, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem, ulong _external) @extern("bgfx_create_texture_2d");
// Create texture with size based on back-buffer ratio. Texture will maintain ratio
// if back buffer resolution changes.
@@ -2340,7 +2352,8 @@ extern fn TextureHandle create_texture_2d_scaled(BackbufferRatio _ratio, bool _h
// _format : `Texture format. See: `TextureFormat::Enum`.`
// _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
// _mem : `Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.`
extern fn TextureHandle create_texture_3d(ushort _width, ushort _height, ushort _depth, bool _hasMips, TextureFormat _format, ulong _flags, Memory* _mem) @extern("bgfx_create_texture_3d");
// _external : `Native API pointer to texture.`
extern fn TextureHandle create_texture_3d(ushort _width, ushort _height, ushort _depth, bool _hasMips, TextureFormat _format, ulong _flags, Memory* _mem, ulong _external) @extern("bgfx_create_texture_3d");
// Create Cube texture.
// _size : `Cube side size.`
@@ -2348,8 +2361,9 @@ extern fn TextureHandle create_texture_3d(ushort _width, ushort _height, ushort
// _numLayers : `Number of layers in texture array. Must be 1 if caps `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.`
// _format : `Texture format. See: `TextureFormat::Enum`.`
// _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
// _mem : `Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.`
extern fn TextureHandle create_texture_cube(ushort _size, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem) @extern("bgfx_create_texture_cube");
// _mem : `Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than`
// _external : `Native API pointer to texture.`
extern fn TextureHandle create_texture_cube(ushort _size, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem, ulong _external) @extern("bgfx_create_texture_cube");
// Update 2D texture.
// @attention It's valid to update only mutable texture. See `bgfx::createTexture2D` for more info.

View File

@@ -738,6 +738,11 @@ public static partial class bgfx
/// </summary>
ReadBack = 0x0000800000000000,
/// <summary>
/// Texture is shared with other device or other process.
/// </summary>
ExternalShared = 0x0001000000000000,
/// <summary>
/// Render target MSAAx2 mode.
/// </summary>
@@ -1121,50 +1126,60 @@ public static partial class bgfx
/// </summary>
TextureDirectAccess = 0x0000000000400000,
/// <summary>
/// External texture is supported.
/// </summary>
TextureExternal = 0x0000000000800000,
/// <summary>
/// External shared texture is supported.
/// </summary>
TextureExternalShared = 0x0000000001000000,
/// <summary>
/// Read-back texture is supported.
/// </summary>
TextureReadBack = 0x0000000000800000,
TextureReadBack = 0x0000000002000000,
/// <summary>
/// 2D texture array is supported.
/// </summary>
Texture2dArray = 0x0000000001000000,
Texture2dArray = 0x0000000004000000,
/// <summary>
/// 3D textures are supported.
/// </summary>
Texture3d = 0x0000000002000000,
Texture3d = 0x0000000008000000,
/// <summary>
/// Transparent back buffer supported.
/// </summary>
TransparentBackbuffer = 0x0000000004000000,
TransparentBackbuffer = 0x0000000010000000,
/// <summary>
/// Variable Rate Shading
/// </summary>
VariableRateShading = 0x0000000008000000,
VariableRateShading = 0x0000000020000000,
/// <summary>
/// Vertex attribute half-float is supported.
/// </summary>
VertexAttribHalf = 0x0000000010000000,
VertexAttribHalf = 0x0000000040000000,
/// <summary>
/// Vertex attribute 10_10_10_2 is supported.
/// </summary>
VertexAttribUint10 = 0x0000000020000000,
VertexAttribUint10 = 0x0000000080000000,
/// <summary>
/// Rendering with VertexID only is supported.
/// </summary>
VertexId = 0x0000000040000000,
VertexId = 0x0000000100000000,
/// <summary>
/// Viewport layer is available in vertex shader.
/// </summary>
ViewportLayerArray = 0x0000000080000000,
ViewportLayerArray = 0x0000000200000000,
/// <summary>
/// All texture compare modes are supported.
@@ -2182,6 +2197,7 @@ public static partial class bgfx
public void* ndt;
public void* nwh;
public void* context;
public void* queue;
public void* backBuffer;
public void* backBufferDS;
public NativeWindowHandleType type;
@@ -3187,9 +3203,10 @@ public static partial class bgfx
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
/// <param name="_external">Native API pointer to texture.</param>
///
[DllImport(DllName, EntryPoint="bgfx_create_texture_2d", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe TextureHandle create_texture_2d(ushort _width, ushort _height, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem);
public static extern unsafe TextureHandle create_texture_2d(ushort _width, ushort _height, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem, ulong _external);
/// <summary>
/// Create texture with size based on back-buffer ratio. Texture will maintain ratio
@@ -3216,9 +3233,10 @@ public static partial class bgfx
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
/// <param name="_external">Native API pointer to texture.</param>
///
[DllImport(DllName, EntryPoint="bgfx_create_texture_3d", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe TextureHandle create_texture_3d(ushort _width, ushort _height, ushort _depth, bool _hasMips, TextureFormat _format, ulong _flags, Memory* _mem);
public static extern unsafe TextureHandle create_texture_3d(ushort _width, ushort _height, ushort _depth, bool _hasMips, TextureFormat _format, ulong _flags, Memory* _mem, ulong _external);
/// <summary>
/// Create Cube texture.
@@ -3229,10 +3247,11 @@ public static partial class bgfx
/// <param name="_numLayers">Number of layers in texture array. Must be 1 if caps `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.</param>
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than</param>
/// <param name="_external">Native API pointer to texture.</param>
///
[DllImport(DllName, EntryPoint="bgfx_create_texture_cube", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe TextureHandle create_texture_cube(ushort _size, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem);
public static extern unsafe TextureHandle create_texture_cube(ushort _size, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem, ulong _external);
/// <summary>
/// Update 2D texture.

View File

@@ -9,7 +9,7 @@ import bindbc.common.types: c_int64, c_uint64, va_list;
import bindbc.bgfx.config;
static import bgfx.impl;
enum uint apiVersion = 136;
enum uint apiVersion = 137;
alias ViewID = ushort;
@@ -329,13 +329,14 @@ enum Buffer: Buffer_{
alias Texture_ = ulong;
enum Texture: Texture_{
none = 0x0000_0000_0000_0000,
msaaSample = 0x0000_0008_0000_0000, ///Texture will be used for MSAA sampling.
rt = 0x0000_0010_0000_0000, ///Render target no MSAA.
computeWrite = 0x0000_1000_0000_0000, ///Texture will be used for compute write.
srgb = 0x0000_2000_0000_0000, ///Sample texture as sRGB.
blitDst = 0x0000_4000_0000_0000, ///Texture will be used as blit destination.
readBack = 0x0000_8000_0000_0000, ///Texture will be used for read back from GPU.
none = 0x0000_0000_0000_0000,
msaaSample = 0x0000_0008_0000_0000, ///Texture will be used for MSAA sampling.
rt = 0x0000_0010_0000_0000, ///Render target no MSAA.
computeWrite = 0x0000_1000_0000_0000, ///Texture will be used for compute write.
srgb = 0x0000_2000_0000_0000, ///Sample texture as sRGB.
blitDst = 0x0000_4000_0000_0000, ///Texture will be used as blit destination.
readBack = 0x0000_8000_0000_0000, ///Texture will be used for read back from GPU.
externalShared = 0x0001_0000_0000_0000, ///Texture is shared with other device or other process.
}
alias TextureRTMSAA_ = ulong;
@@ -514,15 +515,17 @@ enum CapFlags: CapFlags_{
textureCompareReserved = 0x0000_0000_0010_0000,
textureCubeArray = 0x0000_0000_0020_0000, ///Cubemap texture array is supported.
textureDirectAccess = 0x0000_0000_0040_0000, ///CPU direct access to GPU texture memory.
textureReadBack = 0x0000_0000_0080_0000, ///Read-back texture is supported.
texture2DArray = 0x0000_0000_0100_0000, ///2D texture array is supported.
texture3D = 0x0000_0000_0200_0000, ///3D textures are supported.
transparentBackbuffer = 0x0000_0000_0400_0000, ///Transparent back buffer supported.
variableRateShading = 0x0000_0000_0800_0000, ///Variable Rate Shading
vertexAttribHalf = 0x0000_0000_1000_0000, ///Vertex attribute half-float is supported.
vertexAttribUint10 = 0x0000_0000_2000_0000, ///Vertex attribute 10_10_10_2 is supported.
vertexID = 0x0000_0000_4000_0000, ///Rendering with VertexID only is supported.
viewportLayerArray = 0x0000_0000_8000_0000, ///Viewport layer is available in vertex shader.
textureExternal = 0x0000_0000_0080_0000, ///External texture is supported.
textureExternalShared = 0x0000_0000_0100_0000, ///External shared texture is supported.
textureReadBack = 0x0000_0000_0200_0000, ///Read-back texture is supported.
texture2DArray = 0x0000_0000_0400_0000, ///2D texture array is supported.
texture3D = 0x0000_0000_0800_0000, ///3D textures are supported.
transparentBackbuffer = 0x0000_0000_1000_0000, ///Transparent back buffer supported.
variableRateShading = 0x0000_0000_2000_0000, ///Variable Rate Shading
vertexAttribHalf = 0x0000_0000_4000_0000, ///Vertex attribute half-float is supported.
vertexAttribUint10 = 0x0000_0000_8000_0000, ///Vertex attribute 10_10_10_2 is supported.
vertexID = 0x0000_0001_0000_0000, ///Rendering with VertexID only is supported.
viewportLayerArray = 0x0000_0002_0000_0000, ///Viewport layer is available in vertex shader.
textureCompareAll = 0x0000_0000_0018_0000, ///All texture compare modes are supported.
}
@@ -1122,6 +1125,7 @@ extern(C++, "bgfx") struct PlatformData{
will create context/device.
*/
void* context;
void* queue; ///D3D12 Queue. If `NULL` bgfx will create queue.
/**
GL back-buffer, or D3D render target view. If `NULL` bgfx will
@@ -2576,8 +2580,9 @@ mixin(joinFnBinds((){
mem = Texture data. If `_mem` is non-NULL, created texture will be immutable. If
`_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than
1, expected memory layout is texture and all mips together for each array element.
external = Native API pointer to texture.
*/
{q{TextureHandle}, q{createTexture2D}, q{ushort width, ushort height, bool hasMIPs, ushort numLayers, bgfx.impl.TextureFormat.Enum format, c_uint64 flags=Texture.none|Sampler.none, const(Memory)* mem=null}, ext: `C++, "bgfx"`},
{q{TextureHandle}, q{createTexture2D}, q{ushort width, ushort height, bool hasMIPs, ushort numLayers, bgfx.impl.TextureFormat.Enum format, c_uint64 flags=Texture.none|Sampler.none, const(Memory)* mem=null, c_uint64 external=0}, ext: `C++, "bgfx"`},
/**
* Create texture with size based on back-buffer ratio. Texture will maintain ratio
@@ -2614,8 +2619,9 @@ mixin(joinFnBinds((){
mem = Texture data. If `_mem` is non-NULL, created texture will be immutable. If
`_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than
1, expected memory layout is texture and all mips together for each array element.
external = Native API pointer to texture.
*/
{q{TextureHandle}, q{createTexture3D}, q{ushort width, ushort height, ushort depth, bool hasMIPs, bgfx.impl.TextureFormat.Enum format, c_uint64 flags=Texture.none|Sampler.none, const(Memory)* mem=null}, ext: `C++, "bgfx"`},
{q{TextureHandle}, q{createTexture3D}, q{ushort width, ushort height, ushort depth, bool hasMIPs, bgfx.impl.TextureFormat.Enum format, c_uint64 flags=Texture.none|Sampler.none, const(Memory)* mem=null, c_uint64 external=0}, ext: `C++, "bgfx"`},
/**
* Create Cube texture.
@@ -2633,9 +2639,9 @@ mixin(joinFnBinds((){
sampling.
mem = Texture data. If `_mem` is non-NULL, created texture will be immutable. If
`_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than
1, expected memory layout is texture and all mips together for each array element.
external = Native API pointer to texture.
*/
{q{TextureHandle}, q{createTextureCube}, q{ushort size, bool hasMIPs, ushort numLayers, bgfx.impl.TextureFormat.Enum format, c_uint64 flags=Texture.none|Sampler.none, const(Memory)* mem=null}, ext: `C++, "bgfx"`},
{q{TextureHandle}, q{createTextureCube}, q{ushort size, bool hasMIPs, ushort numLayers, bgfx.impl.TextureFormat.Enum format, c_uint64 flags=Texture.none|Sampler.none, const(Memory)* mem=null, c_uint64 external=0}, ext: `C++, "bgfx"`},
/**
* Update 2D texture.

View File

@@ -453,6 +453,9 @@ pub const TextureFlags_BlitDst: TextureFlags = 0x0000400000000000
/// Texture will be used for read back from GPU.
pub const TextureFlags_ReadBack: TextureFlags = 0x0000800000000000;
/// Texture is shared with other device or other process.
pub const TextureFlags_ExternalShared: TextureFlags = 0x0001000000000000;
/// Render target MSAAx2 mode.
pub const TextureFlags_RtMsaaX2: TextureFlags = 0x0000002000000000;
@@ -693,32 +696,38 @@ pub const CapsFlags_TextureCubeArray: CapsFlags = 0x0000000000200000;
/// CPU direct access to GPU texture memory.
pub const CapsFlags_TextureDirectAccess: CapsFlags = 0x0000000000400000;
/// External texture is supported.
pub const CapsFlags_TextureExternal: CapsFlags = 0x0000000000800000;
/// External shared texture is supported.
pub const CapsFlags_TextureExternalShared: CapsFlags = 0x0000000001000000;
/// Read-back texture is supported.
pub const CapsFlags_TextureReadBack: CapsFlags = 0x0000000000800000;
pub const CapsFlags_TextureReadBack: CapsFlags = 0x0000000002000000;
/// 2D texture array is supported.
pub const CapsFlags_Texture2DArray: CapsFlags = 0x0000000001000000;
pub const CapsFlags_Texture2DArray: CapsFlags = 0x0000000004000000;
/// 3D textures are supported.
pub const CapsFlags_Texture3D: CapsFlags = 0x0000000002000000;
pub const CapsFlags_Texture3D: CapsFlags = 0x0000000008000000;
/// Transparent back buffer supported.
pub const CapsFlags_TransparentBackbuffer: CapsFlags = 0x0000000004000000;
pub const CapsFlags_TransparentBackbuffer: CapsFlags = 0x0000000010000000;
/// Variable Rate Shading
pub const CapsFlags_VariableRateShading: CapsFlags = 0x0000000008000000;
pub const CapsFlags_VariableRateShading: CapsFlags = 0x0000000020000000;
/// Vertex attribute half-float is supported.
pub const CapsFlags_VertexAttribHalf: CapsFlags = 0x0000000010000000;
pub const CapsFlags_VertexAttribHalf: CapsFlags = 0x0000000040000000;
/// Vertex attribute 10_10_10_2 is supported.
pub const CapsFlags_VertexAttribUint10: CapsFlags = 0x0000000020000000;
pub const CapsFlags_VertexAttribUint10: CapsFlags = 0x0000000080000000;
/// Rendering with VertexID only is supported.
pub const CapsFlags_VertexId: CapsFlags = 0x0000000040000000;
pub const CapsFlags_VertexId: CapsFlags = 0x0000000100000000;
/// Viewport layer is available in vertex shader.
pub const CapsFlags_ViewportLayerArray: CapsFlags = 0x0000000080000000;
pub const CapsFlags_ViewportLayerArray: CapsFlags = 0x0000000200000000;
/// All texture compare modes are supported.
pub const CapsFlags_TextureCompareAll: CapsFlags = 0x0000000000180000;
@@ -1391,6 +1400,7 @@ pub const Caps = extern struct {
ndt: ?*anyopaque,
nwh: ?*anyopaque,
context: ?*anyopaque,
queue: ?*anyopaque,
backBuffer: ?*anyopaque,
backBufferDS: ?*anyopaque,
type: NativeWindowHandleType,
@@ -2568,10 +2578,11 @@ extern fn bgfx_create_texture(_mem: [*c]const Memory, _flags: u64, _skip: u8, _i
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
pub inline fn createTexture2D(_width: u16, _height: u16, _hasMips: bool, _numLayers: u16, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory) TextureHandle {
return bgfx_create_texture_2d(_width, _height, _hasMips, _numLayers, _format, _flags, _mem);
/// <param name="_external">Native API pointer to texture.</param>
pub inline fn createTexture2D(_width: u16, _height: u16, _hasMips: bool, _numLayers: u16, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory, _external: u64) TextureHandle {
return bgfx_create_texture_2d(_width, _height, _hasMips, _numLayers, _format, _flags, _mem, _external);
}
extern fn bgfx_create_texture_2d(_width: u16, _height: u16, _hasMips: bool, _numLayers: u16, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory) TextureHandle;
extern fn bgfx_create_texture_2d(_width: u16, _height: u16, _hasMips: bool, _numLayers: u16, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory, _external: u64) TextureHandle;
/// Create texture with size based on back-buffer ratio. Texture will maintain ratio
/// if back buffer resolution changes.
@@ -2593,10 +2604,11 @@ extern fn bgfx_create_texture_2d_scaled(_ratio: BackbufferRatio, _hasMips: bool,
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
pub inline fn createTexture3D(_width: u16, _height: u16, _depth: u16, _hasMips: bool, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory) TextureHandle {
return bgfx_create_texture_3d(_width, _height, _depth, _hasMips, _format, _flags, _mem);
/// <param name="_external">Native API pointer to texture.</param>
pub inline fn createTexture3D(_width: u16, _height: u16, _depth: u16, _hasMips: bool, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory, _external: u64) TextureHandle {
return bgfx_create_texture_3d(_width, _height, _depth, _hasMips, _format, _flags, _mem, _external);
}
extern fn bgfx_create_texture_3d(_width: u16, _height: u16, _depth: u16, _hasMips: bool, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory) TextureHandle;
extern fn bgfx_create_texture_3d(_width: u16, _height: u16, _depth: u16, _hasMips: bool, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory, _external: u64) TextureHandle;
/// Create Cube texture.
/// <param name="_size">Cube side size.</param>
@@ -2604,11 +2616,12 @@ extern fn bgfx_create_texture_3d(_width: u16, _height: u16, _depth: u16, _hasMip
/// <param name="_numLayers">Number of layers in texture array. Must be 1 if caps `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.</param>
/// <param name="_format">Texture format. See: `TextureFormat::Enum`.</param>
/// <param name="_flags">Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.</param>
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.</param>
pub inline fn createTextureCube(_size: u16, _hasMips: bool, _numLayers: u16, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory) TextureHandle {
return bgfx_create_texture_cube(_size, _hasMips, _numLayers, _format, _flags, _mem);
/// <param name="_mem">Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than</param>
/// <param name="_external">Native API pointer to texture.</param>
pub inline fn createTextureCube(_size: u16, _hasMips: bool, _numLayers: u16, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory, _external: u64) TextureHandle {
return bgfx_create_texture_cube(_size, _hasMips, _numLayers, _format, _flags, _mem, _external);
}
extern fn bgfx_create_texture_cube(_size: u16, _hasMips: bool, _numLayers: u16, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory) TextureHandle;
extern fn bgfx_create_texture_cube(_size: u16, _hasMips: bool, _numLayers: u16, _format: TextureFormat, _flags: u64, _mem: [*c]const Memory, _external: u64) TextureHandle;
/// Update 2D texture.
/// @attention It's valid to update only mutable texture. See `bgfx::createTexture2D` for more info.