Skip to content

Commit

Permalink
0.1.2: update bgfx to upstream 11/6/2021 (#60)
Browse files Browse the repository at this point in the history
Updates bgfx to upstream version (API 115)
  • Loading branch information
PyryM authored Jun 11, 2021
1 parent 530a65a commit 2d07ee2
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 196 deletions.
8 changes: 4 additions & 4 deletions cmake/bgfx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(ExternalProject)
# Download `bx` and extract source path.
ExternalProject_Add(bx_EXTERNAL
GIT_REPOSITORY "https://github.com/bkaradzic/bx.git"
GIT_TAG "f939b2c3172b1c19f15659613b2f9f9de1f5e820"
GIT_TAG "51f25ba638b9cb35eb2ac078f842a4bed0746d56"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
Expand All @@ -21,7 +21,7 @@ set(bx_GENIE "${SOURCE_DIR}/tools/bin/${bx_SYSTEM_NAME}/genie")
# Download `bimg` and extract source path.
ExternalProject_Add(bimg_EXTERNAL
GIT_REPOSITORY "https://github.com/bkaradzic/bimg.git"
GIT_TAG "7b70810f4bfd2cf81c755c413c66e0e82ea8acc5"
GIT_TAG "8355d36befc90c1db82fca8e54f38bfb7eeb3530"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
Expand Down Expand Up @@ -75,8 +75,8 @@ endif()
# and build it using `bx`.
ExternalProject_Add(bgfx_EXTERNAL
DEPENDS bx_EXTERNAL bimg_EXTERNAL
GIT_REPOSITORY "https://github.com/pyrym/bgfx.git"
GIT_TAG "e368f78c9562e37c071e56b754e3c712d3601ef1"
GIT_REPOSITORY "https://github.com/bkaradzic/bgfx.git"
GIT_TAG "e0d26507dc1982b53c7f80364637a9a2098f5055"
CONFIGURE_COMMAND ${bgfx_CONFIGURE_COMMAND}
BUILD_COMMAND ${bgfx_BUILD_COMMAND}
INSTALL_COMMAND ""
Expand Down
6 changes: 4 additions & 2 deletions dist/include/bgfx_truss.c99.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ typedef struct bgfx_init_s {
bgfx_renderer_type_t type;
uint16_t vendorId;
uint16_t deviceId;
uint64_t capabilities;
bool debug;
bool profile;
bgfx_platform_data_t platformData;
Expand Down Expand Up @@ -501,7 +502,7 @@ typedef struct bgfx_encoder_s bgfx_encoder_t;
const bgfx_memory_t* bgfx_alloc(uint32_t _size);
void bgfx_alloc_instance_data_buffer(bgfx_instance_data_buffer_t* _idb, uint32_t _num, uint16_t _stride);
uint32_t bgfx_alloc_transform(bgfx_transform_t* _transform, uint16_t _num);
bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _layout, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices);
bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_layout_t * _layout, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices, bool _index32);
void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num, bool _index32);
void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_layout_t * _layout);
void bgfx_attachment_init(bgfx_attachment_t* _this, bgfx_texture_handle_t _handle, bgfx_access_t _access, uint16_t _layer, uint16_t _numLayers, uint16_t _mip, uint8_t _resolve);
Expand Down Expand Up @@ -593,7 +594,7 @@ void bgfx_encoder_submit_occlusion_query(bgfx_encoder_t* _this, bgfx_view_id_t _
void bgfx_encoder_touch(bgfx_encoder_t* _this, bgfx_view_id_t _id);
uint32_t bgfx_frame(bool _capture);
uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t _stride);
uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num);
uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num, bool _index32);
uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_layout_t * _layout);
const bgfx_caps_t* bgfx_get_caps(void);
void* bgfx_get_direct_access_ptr(bgfx_texture_handle_t _handle);
Expand All @@ -609,6 +610,7 @@ bgfx_texture_handle_t bgfx_get_texture(bgfx_frame_buffer_handle_t _handle, uint8
void bgfx_get_uniform_info(bgfx_uniform_handle_t _handle, bgfx_uniform_info_t * _info);
bool bgfx_init(const bgfx_init_t * _init);
void bgfx_init_ctor(bgfx_init_t* _init);
bool bgfx_is_frame_buffer_valid(uint8_t _num, const bgfx_attachment_t* _attachment);
bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size);
const bgfx_memory_t* bgfx_make_ref_release(const void* _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void* _userData);
Expand Down
4 changes: 2 additions & 2 deletions dist/include/bgfxdefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD

#define BGFX_API_VERSION UINT32_C(112)
#define BGFX_API_VERSION UINT32_C(115)

/**
* Color RGB/alpha/depth write. When it's not specified write will be disabled.
Expand Down Expand Up @@ -262,7 +262,7 @@
#define BGFX_DISCARD_BINDINGS UINT8_C(0x01) //!< Discard texture sampler and buffer bindings.
#define BGFX_DISCARD_INDEX_BUFFER UINT8_C(0x02) //!< Discard index buffer.
#define BGFX_DISCARD_INSTANCE_DATA UINT8_C(0x04) //!< Discard instance data.
#define BGFX_DISCARD_STATE UINT8_C(0x08) //!< Discard state.
#define BGFX_DISCARD_STATE UINT8_C(0x08) //!< Discard state and uniform bindings.
#define BGFX_DISCARD_TRANSFORM UINT8_C(0x10) //!< Discard transform.
#define BGFX_DISCARD_VERTEX_STREAMS UINT8_C(0x20) //!< Discard vertex streams.
#define BGFX_DISCARD_ALL UINT8_C(0xff) //!< Discard all states.
Expand Down
30 changes: 23 additions & 7 deletions dist/scripts/dev/bgfxgen.moon
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,21 @@ remove_comment = (s) ->
fix5p1 = (data) ->
lines = sutil.split_lines data
outlines = {}
cur_enum = nil
for linepos = 1, #lines
curline = sutil.strip lines[linepos]
curline = remove_comment sutil.strip lines[linepos]
if (curline\sub 1,4) == "enum"
cur_enum = curline\sub 5,-1
elseif cur_enum and curline == ""
if (outlines[#outlines]\sub -2,-1) != "()"
print("Enum missing function call: #{cur_enum}")
outlines[#outlines] = outlines[#outlines] .. "()"
cur_enum = nil

if (curline\sub 1,2) == "()"
outlines[#outlines] = (remove_comment outlines[#outlines]) .. curline
outlines[#outlines] = outlines[#outlines] .. curline
else
outlines[#outlines+1] = lines[linepos]
outlines[#outlines+1] = curline
temp = io.open "bleh.lua", "wt"
temp\write table.concat outlines, "\n"
temp\close!
Expand All @@ -96,7 +105,8 @@ key_sorted_concat = (t, sep) ->
ordered_concat t, sorted_keys, sep

exec_in = (env, fn) ->
chunk, err = loadstring fix5p1 rawload fn
src = fix5p1 rawload fn
chunk, err = loadstring src
if not chunk
truss.error "Error parsing #{fn}: #{err}"
setfenv chunk, env
Expand All @@ -109,12 +119,18 @@ load_idl = (buildpath) ->
idl = exec_in env, "#{path}/scripts/idl.lua"
exec_in idl, "#{path}/scripts/bgfx.idl"

BANNED_TYPES = {"va_list"}

is_api_func = (line) ->
parts = sutil.split " ", line
if parts[1] != "BGFX_C_API" then return nil
api_key = (parts[2] != "const" and parts[3]) or parts[4] or line
api_key = (sutil.split "%(", api_key)[1]
(table.concat [p for p in *parts[2,]], " "), api_key
signature = table.concat [p for p in *parts[2,]], " "
for bad_type in *BANNED_TYPES
if line\find bad_type
signature = "//" .. signature
signature, api_key

get_functions = (buildpath) ->
-- generating function signatures from the IDL is too much of a pain
Expand Down Expand Up @@ -294,8 +310,8 @@ gen_header = (buildpath) ->
}

export init = ->
bpath = "../build"
print "Copying files"
bpath = truss.args[3] or "../build"
print "Copying files from #{bpath}"
copy_files bpath
print "Generating include/bgfx_truss.c99.h"
truss.save_string "include/bgfx_truss.c99.h", (gen_header bpath)
Expand Down
2 changes: 1 addition & 1 deletion dist/scripts/dev/buildshaders.moon
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ WIN_SHADER_TYPES = {
}
PLATFORMS = {
windows: "dx11",
linux: "glsl",
--linux: "glsl",
osx: "mtl",
vulkan: "spirv"
}
Expand Down
2 changes: 1 addition & 1 deletion dist/scripts/examples/logo.t
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function init()
async.await_frames(5)
add_2d_drawable(textbox, {
x = 390, y = 10, w = 220, h = 120,
font_size = 100, text = '0.1.α'
font_size = 100, text = truss.C.get_version()
})
if gif_mode then return end
-- spawn caps
Expand Down
2 changes: 1 addition & 1 deletion dist/scripts/gfx/bgfx_constants.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--Autogenerated bgfx constants
return {
BGFX_API_VERSION = 0x70ULL,
BGFX_API_VERSION = 0x73ULL,
BGFX_STATE_WRITE_R = 0x1ULL,
BGFX_STATE_WRITE_G = 0x2ULL,
BGFX_STATE_WRITE_B = 0x4ULL,
Expand Down
12 changes: 6 additions & 6 deletions dist/scripts/gfx/geometry.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ function TransientGeometry:allocate(n_verts, n_indices, vertinfo)
return
end

local index_type = uint16
if n_verts >= 2^16 then
truss.error("TransientGeometry [" .. self.name ..
"] cannot have more then 2^16 vertices.")
return false
index_type = uint32
end

local verts_available = bgfx.get_avail_transient_vertex_buffer(n_verts,
Expand All @@ -66,16 +65,17 @@ function TransientGeometry:allocate(n_verts, n_indices, vertinfo)
log.error("Not enough space to allocate " .. n_verts .. " vertices.")
return false
end
local indices_available = bgfx.get_avail_transient_index_buffer(n_indices)
local indices_available = bgfx.get_avail_transient_index_buffer(n_indices,
index_type == uint32)
if indices_available < n_indices then
log.error("Not enough space to allocate " .. n_indices .. " indices.")
return false
end

bgfx.alloc_transient_buffers(self._transient_vb, vertinfo.vdecl, n_verts,
self._transient_ib, n_indices)
self._transient_ib, n_indices, index_type == uint32)

self.indices = terralib.cast(&uint16, self._transient_ib.data)
self.indices = terralib.cast(&index_type, self._transient_ib.data)
self.verts = terralib.cast(&vertinfo.ttype, self._transient_vb.data)
self.allocated = true

Expand Down
7 changes: 5 additions & 2 deletions dist/shaders/raw/basicpbr/vs_shadowpbr.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
$input a_position, a_normal
$output v_wpos, v_wnormal, v_viewdir, v_shadowcoord
$output v_wpos, v_wnormal, v_viewdir
//, v_shadowcoord

// TODO: get this working or delete

/*
* Copyright 2015 Pyry Matikainen. All rights reserved.
Expand All @@ -25,5 +28,5 @@ void main()

const float shadowMapOffset = 0.001;
vec3 posOffset = a_position + normal.xyz * shadowMapOffset;
v_shadowcoord = mul(u_lightMtx, vec4(posOffset, 1.0) );
//v_shadowcoord = mul(u_lightMtx, vec4(posOffset, 1.0) );
}
Loading

0 comments on commit 2d07ee2

Please sign in to comment.