This commit is contained in:
Бранимир Караџић 2024-03-29 16:36:55 -07:00
parent 8ec4b71303
commit 2ad67a4dfd
15 changed files with 218 additions and 189 deletions

View File

@ -3496,9 +3496,10 @@ public static class bgfx
/// ///
/// <param name="_id">View id.</param> /// <param name="_id">View id.</param>
/// <param name="_name">View name.</param> /// <param name="_name">View name.</param>
/// <param name="_len">View name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
/// ///
[LinkName("bgfx_set_view_name")] [LinkName("bgfx_set_view_name")]
public static extern void set_view_name(ViewId _id, char8* _name); public static extern void set_view_name(ViewId _id, char8* _name, int _len);
/// <summary> /// <summary>
/// Set view rectangle. Draw primitive outside view will be clipped. /// Set view rectangle. Draw primitive outside view will be clipped.
@ -3651,10 +3652,11 @@ public static class bgfx
/// graphics debugging tools. /// graphics debugging tools.
/// </summary> /// </summary>
/// ///
/// <param name="_marker">Marker string.</param> /// <param name="_name">Marker name.</param>
/// <param name="_len">Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
/// ///
[LinkName("bgfx_encoder_set_marker")] [LinkName("bgfx_encoder_set_marker")]
public static extern void encoder_set_marker(Encoder* _this, char8* _marker); public static extern void encoder_set_marker(Encoder* _this, char8* _name, int _len);
/// <summary> /// <summary>
/// Set render states for draw primitive. /// Set render states for draw primitive.
@ -4219,10 +4221,11 @@ public static class bgfx
/// graphics debugging tools. /// graphics debugging tools.
/// </summary> /// </summary>
/// ///
/// <param name="_marker">Marker string.</param> /// <param name="_name">Marker name.</param>
/// <param name="_len">Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
/// ///
[LinkName("bgfx_set_marker")] [LinkName("bgfx_set_marker")]
public static extern void set_marker(char8* _marker); public static extern void set_marker(char8* _name, int _len);
/// <summary> /// <summary>
/// Set render states for draw primitive. /// Set render states for draw primitive.

View File

@ -3452,9 +3452,10 @@ public static partial class bgfx
/// ///
/// <param name="_id">View id.</param> /// <param name="_id">View id.</param>
/// <param name="_name">View name.</param> /// <param name="_name">View name.</param>
/// <param name="_len">View name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
/// ///
[DllImport(DllName, EntryPoint="bgfx_set_view_name", CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, EntryPoint="bgfx_set_view_name", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void set_view_name(ushort _id, [MarshalAs(UnmanagedType.LPStr)] string _name); public static extern unsafe void set_view_name(ushort _id, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len);
/// <summary> /// <summary>
/// Set view rectangle. Draw primitive outside view will be clipped. /// Set view rectangle. Draw primitive outside view will be clipped.
@ -3607,10 +3608,11 @@ public static partial class bgfx
/// graphics debugging tools. /// graphics debugging tools.
/// </summary> /// </summary>
/// ///
/// <param name="_marker">Marker string.</param> /// <param name="_name">Marker name.</param>
/// <param name="_len">Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
/// ///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_marker", CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, EntryPoint="bgfx_encoder_set_marker", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void encoder_set_marker(Encoder* _this, [MarshalAs(UnmanagedType.LPStr)] string _marker); public static extern unsafe void encoder_set_marker(Encoder* _this, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len);
/// <summary> /// <summary>
/// Set render states for draw primitive. /// Set render states for draw primitive.
@ -4175,10 +4177,11 @@ public static partial class bgfx
/// graphics debugging tools. /// graphics debugging tools.
/// </summary> /// </summary>
/// ///
/// <param name="_marker">Marker string.</param> /// <param name="_name">Marker name.</param>
/// <param name="_len">Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
/// ///
[DllImport(DllName, EntryPoint="bgfx_set_marker", CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, EntryPoint="bgfx_set_marker", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void set_marker([MarshalAs(UnmanagedType.LPStr)] string _marker); public static extern unsafe void set_marker([MarshalAs(UnmanagedType.LPStr)] string _name, int _len);
/// <summary> /// <summary>
/// Set render states for draw primitive. /// Set render states for draw primitive.

View File

@ -10,7 +10,7 @@ import bindbc.bgfx.config;
import bindbc.common.types: c_int64, c_uint64, va_list; import bindbc.common.types: c_int64, c_uint64, va_list;
static import bgfx.fakeenum; static import bgfx.fakeenum;
enum uint apiVersion = 126; enum uint apiVersion = 127;
alias ViewID = ushort; alias ViewID = ushort;
@ -1386,9 +1386,11 @@ extern(C++, "bgfx") struct Encoder{
Sets a debug marker. This allows you to group graphics calls together for easy browsing in Sets a debug marker. This allows you to group graphics calls together for easy browsing in
graphics debugging tools. graphics debugging tools.
Params: Params:
marker = Marker string. name = Marker name.
len = Marker name length (if length is INT32_MAX, it's expected
that _name is zero terminated string.
*/ */
{q{void}, q{setMarker}, q{const(char)* marker}, ext: `C++`}, {q{void}, q{setMarker}, q{const(char)* name, int len=int.max}, ext: `C++`},
/** /**
Set render states for draw primitive. Set render states for draw primitive.
@ -2872,8 +2874,10 @@ mixin(joinFnBinds((){
Params: Params:
id = View id. id = View id.
name = View name. name = View name.
len = View name length (if length is INT32_MAX, it's expected
that _name is zero terminated string.
*/ */
{q{void}, q{setViewName}, q{ViewID id, const(char)* name}, ext: `C++, "bgfx"`}, {q{void}, q{setViewName}, q{ViewID id, const(char)* name, int len=int.max}, ext: `C++, "bgfx"`},
/** /**
* Set view rectangle. Draw primitive outside view will be clipped. * Set view rectangle. Draw primitive outside view will be clipped.
@ -3084,9 +3088,11 @@ mixin(joinFnBinds((){
* Sets a debug marker. This allows you to group graphics calls together for easy browsing in * Sets a debug marker. This allows you to group graphics calls together for easy browsing in
* graphics debugging tools. * graphics debugging tools.
Params: Params:
marker = Marker string. name = Marker name.
len = Marker name length (if length is INT32_MAX, it's expected
that _name is zero terminated string.
*/ */
{q{void}, q{setMarker}, q{const(char)* marker}, ext: `C++, "bgfx"`}, {q{void}, q{setMarker}, q{const(char)* name, int len=int.max}, ext: `C++, "bgfx"`},
/** /**
* Set render states for draw primitive. * Set render states for draw primitive.

View File

@ -1549,9 +1549,10 @@ pub const Init = extern struct {
pub const Encoder = opaque { pub const Encoder = opaque {
/// Sets a debug marker. This allows you to group graphics calls together for easy browsing in /// Sets a debug marker. This allows you to group graphics calls together for easy browsing in
/// graphics debugging tools. /// graphics debugging tools.
/// <param name="_marker">Marker string.</param> /// <param name="_name">Marker name.</param>
pub inline fn setMarker(self: ?*Encoder, _marker: [*c]const u8) void { /// <param name="_len">Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
return bgfx_encoder_set_marker(self, _marker); pub inline fn setMarker(self: ?*Encoder, _name: [*c]const u8, _len: i32) void {
return bgfx_encoder_set_marker(self, _name, _len);
} }
/// Set render states for draw primitive. /// Set render states for draw primitive.
/// @remarks /// @remarks
@ -2811,10 +2812,11 @@ extern fn bgfx_set_palette_color_rgba8(_index: u8, _rgba: u32) void;
/// +------ view id /// +------ view id
/// <param name="_id">View id.</param> /// <param name="_id">View id.</param>
/// <param name="_name">View name.</param> /// <param name="_name">View name.</param>
pub inline fn setViewName(_id: ViewId, _name: [*c]const u8) void { /// <param name="_len">View name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
return bgfx_set_view_name(_id, _name); pub inline fn setViewName(_id: ViewId, _name: [*c]const u8, _len: i32) void {
return bgfx_set_view_name(_id, _name, _len);
} }
extern fn bgfx_set_view_name(_id: ViewId, _name: [*c]const u8) void; extern fn bgfx_set_view_name(_id: ViewId, _name: [*c]const u8, _len: i32) void;
/// Set view rectangle. Draw primitive outside view will be clipped. /// Set view rectangle. Draw primitive outside view will be clipped.
/// <param name="_id">View id.</param> /// <param name="_id">View id.</param>
@ -2941,8 +2943,9 @@ extern fn bgfx_encoder_end(_encoder: ?*Encoder) void;
/// Sets a debug marker. This allows you to group graphics calls together for easy browsing in /// Sets a debug marker. This allows you to group graphics calls together for easy browsing in
/// graphics debugging tools. /// graphics debugging tools.
/// <param name="_marker">Marker string.</param> /// <param name="_name">Marker name.</param>
extern fn bgfx_encoder_set_marker(self: ?*Encoder, _marker: [*c]const u8) void; /// <param name="_len">Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
extern fn bgfx_encoder_set_marker(self: ?*Encoder, _name: [*c]const u8, _len: i32) void;
/// Set render states for draw primitive. /// Set render states for draw primitive.
/// @remarks /// @remarks
@ -3303,11 +3306,12 @@ extern fn bgfx_override_internal_texture(_handle: TextureHandle, _width: u16, _h
/// Sets a debug marker. This allows you to group graphics calls together for easy browsing in /// Sets a debug marker. This allows you to group graphics calls together for easy browsing in
/// graphics debugging tools. /// graphics debugging tools.
/// <param name="_marker">Marker string.</param> /// <param name="_name">Marker name.</param>
pub inline fn setMarker(_marker: [*c]const u8) void { /// <param name="_len">Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.</param>
return bgfx_set_marker(_marker); pub inline fn setMarker(_name: [*c]const u8, _len: i32) void {
return bgfx_set_marker(_name, _len);
} }
extern fn bgfx_set_marker(_marker: [*c]const u8) void; extern fn bgfx_set_marker(_name: [*c]const u8, _len: i32) void;
/// Set render states for draw primitive. /// Set render states for draw primitive.
/// @remarks /// @remarks

View File

@ -362,7 +362,7 @@ public:
if (bgfx::isValid(m_rb) ) if (bgfx::isValid(m_rb) )
{ {
struct Packed { uint8_t bgra[4]; } arr = bx::bit_cast<Packed>(m_lumBgra8); struct Packed { uint8_t bgra[4]; } arr = bx::bitCast<Packed>(m_lumBgra8);
float exponent = arr.bgra[3] / 255.0f * 255.0f - 128.0f; float exponent = arr.bgra[3] / 255.0f * 255.0f - 128.0f;
float lumAvg = arr.bgra[2] / 255.0f * bx::exp2(exponent); float lumAvg = arr.bgra[2] / 255.0f * bx::exp2(exponent);

View File

@ -45,7 +45,7 @@ uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
arr.value[2] = uint8_t(_z * 127.0f + 128.0f); arr.value[2] = uint8_t(_z * 127.0f + 128.0f);
arr.value[3] = uint8_t(_w * 127.0f + 128.0f); arr.value[3] = uint8_t(_w * 127.0f + 128.0f);
return bx::bit_cast<uint32_t>(arr); return bx::bitCast<uint32_t>(arr);
} }
static PosTangentBitangentTexcoordVertex s_cubeVertices[24] = static PosTangentBitangentTexcoordVertex s_cubeVertices[24] =

View File

@ -1053,13 +1053,16 @@ namespace bgfx
/// ///
struct Encoder struct Encoder
{ {
/// Sets a debug marker. This allows you to group /// Sets a debug marker. This allows you to group graphics calls together for easy
/// graphics calls together for easy browsing in /// browsing in graphics debugging tools.
/// graphics debugging tools. ///
/// @param[in] _name Marker name.
/// @param[in] _len Marker name length (if length is INT32_MAX, it's expected that _name
/// is zero terminated string.
/// ///
/// @attention C99's equivalent binding is `bgfx_encoder_set_marker`. /// @attention C99's equivalent binding is `bgfx_encoder_set_marker`.
/// ///
void setMarker(const char* _marker); void setMarker(const char* _name, int32_t _len = INT32_MAX);
/// Set render states for draw primitive. /// Set render states for draw primitive.
/// ///
@ -3337,6 +3340,8 @@ namespace bgfx
/// ///
/// @param[in] _id View id. /// @param[in] _id View id.
/// @param[in] _name View name. /// @param[in] _name View name.
/// @param[in] _len View name length (if length is INT32_MAX, it's expected that _name
/// is zero terminated string.
/// ///
/// @remarks /// @remarks
/// This is debug only feature. /// This is debug only feature.
@ -3354,6 +3359,7 @@ namespace bgfx
void setViewName( void setViewName(
ViewId _id ViewId _id
, const char* _name , const char* _name
, int32_t _len = INT32_MAX
); );
/// Set view rectangle. Draw primitive outside view will be clipped. /// Set view rectangle. Draw primitive outside view will be clipped.
@ -3534,11 +3540,16 @@ namespace bgfx
/// ///
void resetView(ViewId _id); void resetView(ViewId _id);
/// Sets debug marker. /// Sets a debug marker. This allows you to group graphics calls together for easy
/// browsing in graphics debugging tools.
///
/// @param[in] _name Marker name.
/// @param[in] _len Marker name length (if length is INT32_MAX, it's expected that _name
/// is zero terminated string.
/// ///
/// @attention C99's equivalent binding is `bgfx_set_marker`. /// @attention C99's equivalent binding is `bgfx_set_marker`.
/// ///
void setMarker(const char* _marker); void setMarker(const char* _name, int32_t _len = INT32_MAX);
/// Set render states for draw primitive. /// Set render states for draw primitive.
/// ///

View File

@ -2225,9 +2225,11 @@ BGFX_C_API void bgfx_set_palette_color_rgba8(uint8_t _index, uint32_t _rgba);
* *
* @param[in] _id View id. * @param[in] _id View id.
* @param[in] _name View name. * @param[in] _name View name.
* @param[in] _len View name length (if length is INT32_MAX, it's expected
* that _name is zero terminated string.
* *
*/ */
BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char* _name); BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char* _name, int32_t _len);
/** /**
* Set view rectangle. Draw primitive outside view will be clipped. * Set view rectangle. Draw primitive outside view will be clipped.
@ -2377,10 +2379,12 @@ BGFX_C_API void bgfx_encoder_end(bgfx_encoder_t* _encoder);
* Sets a debug marker. This allows you to group graphics calls together for easy browsing in * Sets a debug marker. This allows you to group graphics calls together for easy browsing in
* graphics debugging tools. * graphics debugging tools.
* *
* @param[in] _marker Marker string. * @param[in] _name Marker name.
* @param[in] _len Marker name length (if length is INT32_MAX, it's expected
* that _name is zero terminated string.
* *
*/ */
BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char* _marker); BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char* _name, int32_t _len);
/** /**
* Set render states for draw primitive. * Set render states for draw primitive.
@ -2947,10 +2951,12 @@ BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handl
* Sets a debug marker. This allows you to group graphics calls together for easy browsing in * Sets a debug marker. This allows you to group graphics calls together for easy browsing in
* graphics debugging tools. * graphics debugging tools.
* *
* @param[in] _marker Marker string. * @param[in] _name Marker name.
* @param[in] _len Marker name length (if length is INT32_MAX, it's expected
* that _name is zero terminated string.
* *
*/ */
BGFX_C_API void bgfx_set_marker(const char* _marker); BGFX_C_API void bgfx_set_marker(const char* _name, int32_t _len);
/** /**
* Set render states for draw primitive. * Set render states for draw primitive.
@ -3733,7 +3739,7 @@ struct bgfx_interface_vtbl
void (*destroy_occlusion_query)(bgfx_occlusion_query_handle_t _handle); void (*destroy_occlusion_query)(bgfx_occlusion_query_handle_t _handle);
void (*set_palette_color)(uint8_t _index, const float _rgba[4]); void (*set_palette_color)(uint8_t _index, const float _rgba[4]);
void (*set_palette_color_rgba8)(uint8_t _index, uint32_t _rgba); void (*set_palette_color_rgba8)(uint8_t _index, uint32_t _rgba);
void (*set_view_name)(bgfx_view_id_t _id, const char* _name); void (*set_view_name)(bgfx_view_id_t _id, const char* _name, int32_t _len);
void (*set_view_rect)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); void (*set_view_rect)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
void (*set_view_rect_ratio)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, bgfx_backbuffer_ratio_t _ratio); void (*set_view_rect_ratio)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, bgfx_backbuffer_ratio_t _ratio);
void (*set_view_scissor)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); void (*set_view_scissor)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
@ -3746,7 +3752,7 @@ struct bgfx_interface_vtbl
void (*reset_view)(bgfx_view_id_t _id); void (*reset_view)(bgfx_view_id_t _id);
bgfx_encoder_t* (*encoder_begin)(bool _forThread); bgfx_encoder_t* (*encoder_begin)(bool _forThread);
void (*encoder_end)(bgfx_encoder_t* _encoder); void (*encoder_end)(bgfx_encoder_t* _encoder);
void (*encoder_set_marker)(bgfx_encoder_t* _this, const char* _marker); void (*encoder_set_marker)(bgfx_encoder_t* _this, const char* _name, int32_t _len);
void (*encoder_set_state)(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba); void (*encoder_set_state)(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba);
void (*encoder_set_condition)(bgfx_encoder_t* _this, bgfx_occlusion_query_handle_t _handle, bool _visible); void (*encoder_set_condition)(bgfx_encoder_t* _this, bgfx_occlusion_query_handle_t _handle, bool _visible);
void (*encoder_set_stencil)(bgfx_encoder_t* _this, uint32_t _fstencil, uint32_t _bstencil); void (*encoder_set_stencil)(bgfx_encoder_t* _this, uint32_t _fstencil, uint32_t _bstencil);
@ -3792,7 +3798,7 @@ struct bgfx_interface_vtbl
const bgfx_internal_data_t* (*get_internal_data)(void); const bgfx_internal_data_t* (*get_internal_data)(void);
uintptr_t (*override_internal_texture_ptr)(bgfx_texture_handle_t _handle, uintptr_t _ptr); uintptr_t (*override_internal_texture_ptr)(bgfx_texture_handle_t _handle, uintptr_t _ptr);
uintptr_t (*override_internal_texture)(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint64_t _flags); uintptr_t (*override_internal_texture)(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint64_t _flags);
void (*set_marker)(const char* _marker); void (*set_marker)(const char* _name, int32_t _len);
void (*set_state)(uint64_t _state, uint32_t _rgba); void (*set_state)(uint64_t _state, uint32_t _rgba);
void (*set_condition)(bgfx_occlusion_query_handle_t _handle, bool _visible); void (*set_condition)(bgfx_occlusion_query_handle_t _handle, bool _visible);
void (*set_stencil)(uint32_t _fstencil, uint32_t _bstencil); void (*set_stencil)(uint32_t _fstencil, uint32_t _bstencil);

View File

@ -15,7 +15,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD #ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD #define BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_API_VERSION UINT32_C(126) #define BGFX_API_VERSION UINT32_C(127)
/** /**
* Color RGB/alpha/depth write. When it's not specified write will be disabled. * Color RGB/alpha/depth write. When it's not specified write will be disabled.

View File

@ -1,7 +1,7 @@
-- vim: syntax=lua -- vim: syntax=lua
-- bgfx interface -- bgfx interface
version(126) version(127)
typedef "bool" typedef "bool"
typedef "char" typedef "char"
@ -2017,8 +2017,10 @@ func.setPaletteColor { cname = "set_palette_color_rgba8" }
--- ---
func.setViewName func.setViewName
"void" "void"
.id "ViewId" --- View id. .id "ViewId" --- View id.
.name "const char*" --- View name. .name "const char*" --- View name.
.len "int32_t" --- View name length (if length is INT32_MAX, it's expected
{ default = INT32_MAX } --- that _name is zero terminated string.
--- Set view rectangle. Draw primitive outside view will be clipped. --- Set view rectangle. Draw primitive outside view will be clipped.
func.setViewRect func.setViewRect
@ -2154,7 +2156,9 @@ func["end"] { cname = "encoder_end" }
--- graphics debugging tools. --- graphics debugging tools.
func.Encoder.setMarker func.Encoder.setMarker
"void" "void"
.marker "const char*" --- Marker string. .name "const char*" --- Marker name.
.len "int32_t" --- Marker name length (if length is INT32_MAX, it's expected
{ default = INT32_MAX } --- that _name is zero terminated string.
--- Set render states for draw primitive. --- Set render states for draw primitive.
--- ---
@ -2724,7 +2728,9 @@ func.overrideInternal { cname = "override_internal_texture" }
--- graphics debugging tools. --- graphics debugging tools.
func.setMarker func.setMarker
"void" "void"
.marker "const char*" --- Marker string. .name "const char*" --- Marker name.
.len "int32_t" --- Marker name length (if length is INT32_MAX, it's expected
{ default = INT32_MAX } --- that _name is zero terminated string.
--- Set render states for draw primitive. --- Set render states for draw primitive.
--- ---

View File

@ -225,15 +225,6 @@ namespace bgfx
if (kNaturalAlignment >= _align) if (kNaturalAlignment >= _align)
{ {
#if BGFX_CONFIG_MEMORY_TRACKING
if (NULL == _ptr)
{
bx::MutexScope scope(m_mutex);
++m_numBlocks;
m_maxBlocks = bx::max(m_maxBlocks, m_numBlocks);
}
#endif // BGFX_CONFIG_MEMORY_TRACKING
return ::realloc(_ptr, _size); return ::realloc(_ptr, _size);
} }
@ -1514,24 +1505,26 @@ namespace bgfx
void UniformBuffer::writeUniform(UniformType::Enum _type, uint16_t _loc, const void* _value, uint16_t _num) void UniformBuffer::writeUniform(UniformType::Enum _type, uint16_t _loc, const void* _value, uint16_t _num)
{ {
uint32_t opcode = encodeOpcode(_type, _loc, _num, true); const uint32_t opcode = encodeOpcode(_type, _loc, _num, true);
write(opcode); write(opcode);
write(_value, g_uniformTypeSize[_type]*_num); write(_value, g_uniformTypeSize[_type]*_num);
} }
void UniformBuffer::writeUniformHandle(UniformType::Enum _type, uint16_t _loc, UniformHandle _handle, uint16_t _num) void UniformBuffer::writeUniformHandle(UniformType::Enum _type, uint16_t _loc, UniformHandle _handle, uint16_t _num)
{ {
uint32_t opcode = encodeOpcode(_type, _loc, _num, false); const uint32_t opcode = encodeOpcode(_type, _loc, _num, false);
write(opcode); write(opcode);
write(&_handle, sizeof(UniformHandle) ); write(&_handle, sizeof(UniformHandle) );
} }
void UniformBuffer::writeMarker(const char* _marker) void UniformBuffer::writeMarker(const bx::StringView& _name)
{ {
uint16_t num = (uint16_t)bx::strLen(_marker)+1; const uint16_t num = bx::narrowCast<uint16_t>(_name.getLength()+1);
uint32_t opcode = encodeOpcode(bgfx::UniformType::Count, 0, num, true); const uint32_t opcode = encodeOpcode(bgfx::UniformType::Count, 0, num, true);
write(opcode); write(opcode);
write(_marker, num); write(_name.getPtr(), num-1);
const char zero = '\0';
write(&zero, 1);
} }
struct CapsFlags struct CapsFlags
@ -2521,8 +2514,9 @@ namespace bgfx
uint16_t copy; uint16_t copy;
UniformBuffer::decodeOpcode(opcode, type, loc, num, copy); UniformBuffer::decodeOpcode(opcode, type, loc, num, copy);
uint32_t size = g_uniformTypeSize[type]*num; const uint32_t size = g_uniformTypeSize[type]*num;
const char* data = _uniformBuffer->read(size); const char* data = _uniformBuffer->read(size);
if (UniformType::Count > type) if (UniformType::Count > type)
{ {
if (copy) if (copy)
@ -3661,9 +3655,9 @@ namespace bgfx
#define BGFX_ENCODER(_func) reinterpret_cast<EncoderImpl*>(this)->_func #define BGFX_ENCODER(_func) reinterpret_cast<EncoderImpl*>(this)->_func
void Encoder::setMarker(const char* _marker) void Encoder::setMarker(const char* _name, int32_t _len)
{ {
BGFX_ENCODER(setMarker(_marker) ); BGFX_ENCODER(setMarker(bx::StringView(_name, _len) ) );
} }
void Encoder::setState(uint64_t _state, uint32_t _rgba) void Encoder::setState(uint64_t _state, uint32_t _rgba)
@ -5215,10 +5209,10 @@ namespace bgfx
return id < BGFX_CONFIG_MAX_VIEWS; return id < BGFX_CONFIG_MAX_VIEWS;
} }
void setViewName(ViewId _id, const char* _name) void setViewName(ViewId _id, const char* _name, int32_t _len)
{ {
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id); BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewName(_id, _name); s_ctx->setViewName(_id, bx::StringView(_name, _len) );
} }
void setViewRect(ViewId _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) void setViewRect(ViewId _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
@ -5290,10 +5284,10 @@ namespace bgfx
BGFX_FATAL(NULL != s_ctx->m_encoder0, Fatal::DebugCheck \ BGFX_FATAL(NULL != s_ctx->m_encoder0, Fatal::DebugCheck \
, "bgfx is configured to allow only encoder API. See: `BGFX_CONFIG_ENCODER_API_ONLY`.") , "bgfx is configured to allow only encoder API. See: `BGFX_CONFIG_ENCODER_API_ONLY`.")
void setMarker(const char* _marker) void setMarker(const char* _name, int32_t _len)
{ {
BGFX_CHECK_ENCODER0(); BGFX_CHECK_ENCODER0();
s_ctx->m_encoder0->setMarker(_marker); s_ctx->m_encoder0->setMarker(_name, _len);
} }
void setState(uint64_t _state, uint32_t _rgba) void setState(uint64_t _state, uint32_t _rgba)

View File

@ -625,9 +625,9 @@ BGFX_C_API void bgfx_set_palette_color_rgba8(uint8_t _index, uint32_t _rgba)
bgfx::setPaletteColor(_index, _rgba); bgfx::setPaletteColor(_index, _rgba);
} }
BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char* _name) BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char* _name, int32_t _len)
{ {
bgfx::setViewName((bgfx::ViewId)_id, _name); bgfx::setViewName((bgfx::ViewId)_id, _name, _len);
} }
BGFX_C_API void bgfx_set_view_rect(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) BGFX_C_API void bgfx_set_view_rect(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
@ -691,10 +691,10 @@ BGFX_C_API void bgfx_encoder_end(bgfx_encoder_t* _encoder)
bgfx::end((bgfx::Encoder*)_encoder); bgfx::end((bgfx::Encoder*)_encoder);
} }
BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char* _marker) BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char* _name, int32_t _len)
{ {
bgfx::Encoder* This = (bgfx::Encoder*)_this; bgfx::Encoder* This = (bgfx::Encoder*)_this;
This->setMarker(_marker); This->setMarker(_name, _len);
} }
BGFX_C_API void bgfx_encoder_set_state(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba) BGFX_C_API void bgfx_encoder_set_state(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba)
@ -999,9 +999,9 @@ BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handl
return bgfx::overrideInternal(handle.cpp, _width, _height, _numMips, (bgfx::TextureFormat::Enum)_format, _flags); return bgfx::overrideInternal(handle.cpp, _width, _height, _numMips, (bgfx::TextureFormat::Enum)_format, _flags);
} }
BGFX_C_API void bgfx_set_marker(const char* _marker) BGFX_C_API void bgfx_set_marker(const char* _name, int32_t _len)
{ {
bgfx::setMarker(_marker); bgfx::setMarker(_name, _len);
} }
BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba) BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba)

View File

@ -671,8 +671,8 @@ namespace bgfx
|| m_small != _small) || m_small != _small)
{ {
m_small = _small; m_small = _small;
m_width = (uint16_t)width; m_width = bx::narrowCast<uint16_t>(width);
m_height = (uint16_t)height; m_height = bx::narrowCast<uint16_t>(height);
uint32_t size = m_size; uint32_t size = m_size;
m_size = m_width * m_height; m_size = m_width * m_height;
@ -947,6 +947,14 @@ namespace bgfx
write(reinterpret_cast<const uint8_t*>(&_in), sizeof(Type) ); write(reinterpret_cast<const uint8_t*>(&_in), sizeof(Type) );
} }
void write(const bx::StringView& _str)
{
const uint16_t len = bx::narrowCast<uint16_t>(_str.getLength()+1);
write(len);
write(_str.getPtr(), len-1);
write('\0');
}
void read(void* _data, uint32_t _size) void read(void* _data, uint32_t _size)
{ {
BX_ASSERT(m_pos + _size <= m_size BX_ASSERT(m_pos + _size <= m_size
@ -1382,7 +1390,7 @@ namespace bgfx
uint32_t first = bx::atomicFetchAndAddsat<uint32_t>(&m_num, num, BGFX_CONFIG_MAX_MATRIX_CACHE - 1); uint32_t first = bx::atomicFetchAndAddsat<uint32_t>(&m_num, num, BGFX_CONFIG_MAX_MATRIX_CACHE - 1);
BX_WARN(first+num < BGFX_CONFIG_MAX_MATRIX_CACHE, "Matrix cache overflow. %d (max: %d)", first+num, BGFX_CONFIG_MAX_MATRIX_CACHE); BX_WARN(first+num < BGFX_CONFIG_MAX_MATRIX_CACHE, "Matrix cache overflow. %d (max: %d)", first+num, BGFX_CONFIG_MAX_MATRIX_CACHE);
num = bx::min(num, BGFX_CONFIG_MAX_MATRIX_CACHE-1-first); num = bx::min(num, BGFX_CONFIG_MAX_MATRIX_CACHE-1-first);
*_num = (uint16_t)num; *_num = bx::narrowCast<uint16_t>(num);
return first; return first;
} }
@ -1576,7 +1584,7 @@ namespace bgfx
void writeUniform(UniformType::Enum _type, uint16_t _loc, const void* _value, uint16_t _num = 1); void writeUniform(UniformType::Enum _type, uint16_t _loc, const void* _value, uint16_t _num = 1);
void writeUniformHandle(UniformType::Enum _type, uint16_t _loc, UniformHandle _handle, uint16_t _num = 1); void writeUniformHandle(UniformType::Enum _type, uint16_t _loc, UniformHandle _handle, uint16_t _num = 1);
void writeMarker(const char* _marker); void writeMarker(const bx::StringView& _name);
private: private:
UniformBuffer(uint32_t _size) UniformBuffer(uint32_t _size)
@ -2478,7 +2486,7 @@ namespace bgfx
} }
} }
void setMarker(const char* _name) void setMarker(const bx::StringView& _name)
{ {
UniformBuffer::update(&m_frame->m_uniformBuffer[m_uniformIdx]); UniformBuffer::update(&m_frame->m_uniformBuffer[m_uniformIdx]);
UniformBuffer* uniformBuffer = m_frame->m_uniformBuffer[m_uniformIdx]; UniformBuffer* uniformBuffer = m_frame->m_uniformBuffer[m_uniformIdx];
@ -2494,7 +2502,7 @@ namespace bgfx
, _handle.idx , _handle.idx
, getName(_handle) , getName(_handle)
); );
m_uniformSet.insert(_handle.idx); // m_uniformSet.insert(_handle.idx);
} }
UniformBuffer::update(&m_frame->m_uniformBuffer[m_uniformIdx]); UniformBuffer::update(&m_frame->m_uniformBuffer[m_uniformIdx]);
@ -2543,7 +2551,7 @@ namespace bgfx
uint16_t setScissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) uint16_t setScissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
{ {
uint16_t scissor = (uint16_t)m_frame->m_frameCache.m_rectCache.add(_x, _y, _width, _height); uint16_t scissor = bx::narrowCast<uint16_t>(m_frame->m_frameCache.m_rectCache.add(_x, _y, _width, _height) );
m_draw.m_scissor = scissor; m_draw.m_scissor = scissor;
return scissor; return scissor;
} }
@ -3086,7 +3094,7 @@ namespace bgfx
virtual void updateViewName(ViewId _id, const char* _name) = 0; virtual void updateViewName(ViewId _id, const char* _name) = 0;
virtual void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) = 0; virtual void updateUniform(uint16_t _loc, const void* _data, uint32_t _size) = 0;
virtual void invalidateOcclusionQuery(OcclusionQueryHandle _handle) = 0; virtual void invalidateOcclusionQuery(OcclusionQueryHandle _handle) = 0;
virtual void setMarker(const char* _marker, uint16_t _len) = 0; virtual void setMarker(const char* _name, uint16_t _len) = 0;
virtual void setName(Handle _handle, const char* _name, uint16_t _len) = 0; virtual void setName(Handle _handle, const char* _name, uint16_t _len) = 0;
virtual void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) = 0; virtual void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) = 0;
virtual void blitSetup(TextVideoMemBlitter& _blitter) = 0; virtual void blitSetup(TextVideoMemBlitter& _blitter) = 0;
@ -4906,7 +4914,7 @@ namespace bgfx
cmdbuf.write(handle); cmdbuf.write(handle);
cmdbuf.write(uniform.m_type); cmdbuf.write(uniform.m_type);
cmdbuf.write(uniform.m_num); cmdbuf.write(uniform.m_num);
uint8_t len = (uint8_t)bx::strLen(_name)+1; uint8_t len = bx::narrowCast<uint8_t>(bx::strLen(_name)+1);
cmdbuf.write(len); cmdbuf.write(len);
cmdbuf.write(_name, len); cmdbuf.write(_name, len);
} }
@ -4938,7 +4946,7 @@ namespace bgfx
cmdbuf.write(handle); cmdbuf.write(handle);
cmdbuf.write(_type); cmdbuf.write(_type);
cmdbuf.write(_num); cmdbuf.write(_num);
uint8_t len = (uint8_t)bx::strLen(_name)+1; uint8_t len = bx::narrowCast<uint8_t>(bx::strLen(_name)+1);
cmdbuf.write(len); cmdbuf.write(len);
cmdbuf.write(_name, len); cmdbuf.write(_name, len);
@ -5075,15 +5083,13 @@ namespace bgfx
m_colorPaletteDirty = 2; m_colorPaletteDirty = 2;
} }
BGFX_API_FUNC(void setViewName(ViewId _id, const char* _name) ) BGFX_API_FUNC(void setViewName(ViewId _id, const bx::StringView& _name) )
{ {
BGFX_MUTEX_SCOPE(m_resourceApiLock); BGFX_MUTEX_SCOPE(m_resourceApiLock);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::UpdateViewName); CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::UpdateViewName);
cmdbuf.write(_id); cmdbuf.write(_id);
uint16_t len = (uint16_t)bx::strLen(_name)+1; cmdbuf.write(_name);
cmdbuf.write(len);
cmdbuf.write(_name, len);
} }
BGFX_API_FUNC(void setViewRect(ViewId _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) ) BGFX_API_FUNC(void setViewRect(ViewId _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) )

View File

@ -277,6 +277,25 @@ VK_IMPORT_DEVICE
}; };
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) ); BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
struct ImageTest
{
VkImageType type;
VkImageUsageFlags usage;
VkImageCreateFlags flags;
uint32_t formatCaps[2];
};
static const ImageTest s_imageTest[] =
{
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_SAMPLED_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_2D, BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB } },
{ VK_IMAGE_TYPE_3D, VK_IMAGE_USAGE_SAMPLED_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_3D, BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, { BGFX_CAPS_FORMAT_TEXTURE_CUBE, BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER, 0 } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER, 0 } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_STORAGE_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ, 0 } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_STORAGE_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE, 0 } },
};
struct LayerInfo struct LayerInfo
{ {
bool m_supported; bool m_supported;
@ -535,30 +554,25 @@ VK_IMPORT_DEVICE
static void* VKAPI_PTR allocationFunction(void* _userData, size_t _size, size_t _alignment, VkSystemAllocationScope _allocationScope) static void* VKAPI_PTR allocationFunction(void* _userData, size_t _size, size_t _alignment, VkSystemAllocationScope _allocationScope)
{ {
BX_UNUSED(_userData); bx::AllocatorI* allocator = (bx::AllocatorI*)_userData;
return bx::alignedAlloc(g_allocator, _size, bx::max(kMinAlignment, _alignment), bx::Location(s_allocScopeName[_allocationScope], 0) ); return allocator->realloc(NULL, _size, bx::max(kMinAlignment, _alignment), s_allocScopeName[_allocationScope], 0);
} }
static void* VKAPI_PTR reallocationFunction(void* _userData, void* _original, size_t _size, size_t _alignment, VkSystemAllocationScope _allocationScope) static void* VKAPI_PTR reallocationFunction(void* _userData, void* _original, size_t _size, size_t _alignment, VkSystemAllocationScope _allocationScope)
{ {
BX_UNUSED(_userData); bx::AllocatorI* allocator = (bx::AllocatorI*)_userData;
if (_size == 0) { return allocator->realloc(_original, _size, bx::max(kMinAlignment, _alignment), s_allocScopeName[_allocationScope], 0);
bx::alignedFree(g_allocator, _original, 0);
return NULL;
}
return bx::alignedRealloc(g_allocator, _original, _size, bx::max(kMinAlignment, _alignment), bx::Location(s_allocScopeName[_allocationScope], 0) );
} }
static void VKAPI_PTR freeFunction(void* _userData, void* _memory) static void VKAPI_PTR freeFunction(void* _userData, void* _memory)
{ {
BX_UNUSED(_userData);
if (NULL == _memory) if (NULL == _memory)
{ {
return; return;
} }
bx::alignedFree(g_allocator, _memory, 0); bx::AllocatorI* allocator = (bx::AllocatorI*)_userData;
allocator->realloc(_memory, 0, 0, "vkFree", 0);
} }
static void VKAPI_PTR internalAllocationNotification(void* _userData, size_t _size, VkInternalAllocationType _allocationType, VkSystemAllocationScope _allocationScope) static void VKAPI_PTR internalAllocationNotification(void* _userData, size_t _size, VkInternalAllocationType _allocationType, VkSystemAllocationScope _allocationScope)
@ -636,26 +650,17 @@ VK_IMPORT_DEVICE
}; };
VkBool32 VKAPI_PTR debugReportCb( VkBool32 VKAPI_PTR debugReportCb(
VkDebugReportFlagsEXT _flags, VkDebugReportFlagsEXT _flags
VkDebugReportObjectTypeEXT _objectType, , VkDebugReportObjectTypeEXT _objectType
uint64_t _object, , uint64_t _object
size_t _location, , size_t _location
int32_t _messageCode, , int32_t _messageCode
const char* _layerPrefix, , const char* _layerPrefix
const char* _message, , const char* _message
void* _userData , void* _userData
) )
{ {
BX_UNUSED(_flags BX_UNUSED(_flags, _objectType, _object, _location, _messageCode, _layerPrefix, _message, _userData, s_debugReportObjectType);
, _objectType
, _object
, _location
, _messageCode
, _layerPrefix
, _message
, _userData
, s_debugReportObjectType
);
// For more info about 'VUID-VkSwapchainCreateInfoKHR-imageExtent-01274' // For more info about 'VUID-VkSwapchainCreateInfoKHR-imageExtent-01274'
// check https://github.com/KhronosGroup/Vulkan-Docs/issues/1144 // check https://github.com/KhronosGroup/Vulkan-Docs/issues/1144
@ -666,6 +671,7 @@ VK_IMPORT_DEVICE
{ {
return VK_FALSE; return VK_FALSE;
} }
BX_TRACE("%c%c%c%c%c %19s, %s, %d: %s" BX_TRACE("%c%c%c%c%c %19s, %s, %d: %s"
, 0 != (_flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT ) ? 'I' : '-' , 0 != (_flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT ) ? 'I' : '-'
, 0 != (_flags & VK_DEBUG_REPORT_WARNING_BIT_EXT ) ? 'W' : '-' , 0 != (_flags & VK_DEBUG_REPORT_WARNING_BIT_EXT ) ? 'W' : '-'
@ -677,6 +683,7 @@ VK_IMPORT_DEVICE
, _messageCode , _messageCode
, _message , _message
); );
return VK_FALSE; return VK_FALSE;
} }
@ -774,6 +781,7 @@ VK_IMPORT_DEVICE
, layerProperties[layer].implementationVersion , layerProperties[layer].implementationVersion
, layerProperties[layer].description , layerProperties[layer].description
); );
uint32_t numExtensionProperties; uint32_t numExtensionProperties;
result = enumerateExtensionProperties(_physicalDevice result = enumerateExtensionProperties(_physicalDevice
, layerProperties[layer].layerName , layerProperties[layer].layerName
@ -793,7 +801,7 @@ VK_IMPORT_DEVICE
for (uint32_t extension = 0; extension < numExtensionProperties; ++extension) for (uint32_t extension = 0; extension < numExtensionProperties; ++extension)
{ {
bool supported = updateExtension( const bool supported = updateExtension(
extensionProperties[extension].extensionName extensionProperties[extension].extensionName
, extensionProperties[extension].specVersion , extensionProperties[extension].specVersion
, VK_NULL_HANDLE == _physicalDevice , VK_NULL_HANDLE == _physicalDevice
@ -1077,7 +1085,8 @@ VK_IMPORT_DEVICE
imb.subresourceRange.levelCount = _levelCount; imb.subresourceRange.levelCount = _levelCount;
imb.subresourceRange.baseArrayLayer = _baseArrayLayer; imb.subresourceRange.baseArrayLayer = _baseArrayLayer;
imb.subresourceRange.layerCount = _layerCount; imb.subresourceRange.layerCount = _layerCount;
vkCmdPipelineBarrier(_commandBuffer vkCmdPipelineBarrier(
_commandBuffer
, srcStageMask , srcStageMask
, dstStageMask , dstStageMask
, 0 , 0
@ -1308,6 +1317,7 @@ VK_IMPORT
if (BX_ENABLED(BGFX_CONFIG_DEBUG) ) if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
{ {
s_allocationCb.pUserData = g_allocator;
m_allocatorCb = &s_allocationCb; m_allocatorCb = &s_allocationCb;
BX_UNUSED(s_allocationCb); BX_UNUSED(s_allocationCb);
} }
@ -1637,83 +1647,63 @@ VK_IMPORT_INSTANCE
} }
} }
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{ {
struct ImageTest uint16_t support = BGFX_CAPS_FORMAT_TEXTURE_NONE;
const bool depth = bimg::isDepth(bimg::TextureFormat::Enum(ii) );
VkFormat fmt = depth
? s_textureFormat[ii].m_fmtDsv
: s_textureFormat[ii].m_fmt
;
for (uint32_t jj = 0, num = depth ? 1 : 2; jj < num; ++jj)
{ {
VkImageType type; if (VK_FORMAT_UNDEFINED != fmt)
VkImageUsageFlags usage;
VkImageCreateFlags flags;
uint32_t formatCaps[2];
};
const ImageTest imageTest[] =
{
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_SAMPLED_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_2D, BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB } },
{ VK_IMAGE_TYPE_3D, VK_IMAGE_USAGE_SAMPLED_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_3D, BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, { BGFX_CAPS_FORMAT_TEXTURE_CUBE, BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER, 0 } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER, 0 } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_STORAGE_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ, 0 } },
{ VK_IMAGE_TYPE_2D, VK_IMAGE_USAGE_STORAGE_BIT, 0, { BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE, 0 } },
};
for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii)
{
uint16_t support = BGFX_CAPS_FORMAT_TEXTURE_NONE;
const bool depth = bimg::isDepth(bimg::TextureFormat::Enum(ii) );
VkFormat fmt = depth
? s_textureFormat[ii].m_fmtDsv
: s_textureFormat[ii].m_fmt
;
for (uint32_t jj = 0, num = depth ? 1 : 2; jj < num; ++jj)
{ {
if (VK_FORMAT_UNDEFINED != fmt) for (uint32_t test = 0; test < BX_COUNTOF(s_imageTest); ++test)
{ {
for (uint32_t test = 0; test < BX_COUNTOF(imageTest); ++test) const ImageTest& it = s_imageTest[test];
VkImageFormatProperties ifp;
result = vkGetPhysicalDeviceImageFormatProperties(
m_physicalDevice
, fmt
, it.type
, VK_IMAGE_TILING_OPTIMAL
, it.usage
, it.flags
, &ifp
);
if (VK_SUCCESS == result)
{ {
const ImageTest& it = imageTest[test]; support |= it.formatCaps[jj];
VkImageFormatProperties ifp; const bool multisample = VK_SAMPLE_COUNT_1_BIT < ifp.sampleCounts;
result = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice if (it.usage & VK_IMAGE_USAGE_SAMPLED_BIT)
, fmt
, it.type
, VK_IMAGE_TILING_OPTIMAL
, it.usage
, it.flags
, &ifp
);
if (VK_SUCCESS == result)
{ {
support |= it.formatCaps[jj]; support |= 0
| BGFX_CAPS_FORMAT_TEXTURE_VERTEX
| (multisample ? BGFX_CAPS_FORMAT_TEXTURE_MSAA : 0)
;
}
const bool multisample = VK_SAMPLE_COUNT_1_BIT < ifp.sampleCounts; if (it.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) )
if (it.usage & VK_IMAGE_USAGE_SAMPLED_BIT) {
{ support |= 0
support |= 0 | BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN
| BGFX_CAPS_FORMAT_TEXTURE_VERTEX | (multisample ? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA : 0)
| (multisample ? BGFX_CAPS_FORMAT_TEXTURE_MSAA : 0) ;
;
}
if (it.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) )
{
support |= 0
| BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN
| (multisample ? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA : 0)
;
}
} }
} }
} }
fmt = s_textureFormat[ii].m_fmtSrgb;
} }
g_caps.formats[ii] = support; fmt = s_textureFormat[ii].m_fmtSrgb;
} }
g_caps.formats[ii] = support;
} }
vkGetPhysicalDeviceMemoryProperties(m_physicalDevice, &m_memoryProperties); vkGetPhysicalDeviceMemoryProperties(m_physicalDevice, &m_memoryProperties);
@ -1844,7 +1834,7 @@ VK_IMPORT_INSTANCE
dci.ppEnabledLayerNames = enabledLayer; dci.ppEnabledLayerNames = enabledLayer;
dci.enabledExtensionCount = numEnabledExtensions; dci.enabledExtensionCount = numEnabledExtensions;
dci.ppEnabledExtensionNames = enabledExtension; dci.ppEnabledExtensionNames = enabledExtension;
dci.pEnabledFeatures = &m_deviceFeatures; dci.pEnabledFeatures = &m_deviceFeatures;
result = vkCreateDevice( result = vkCreateDevice(
m_physicalDevice m_physicalDevice

View File

@ -1726,7 +1726,7 @@ namespace bgfx
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size) size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
, "%s%f" , "%s%f"
, 0 == jj ? "(" : ", " , 0 == jj ? "(" : ", "
, bx::bit_cast<float>(operand.un.imm32[jj]) , bx::bitCast<float>(operand.un.imm32[jj])
); );
} }