summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
authorGravatarGravatar Julian Sikorski <belegdol+github@gmail.com>2019-10-13 13:50:38 +0200
committerGravatarGravatar R. Belmont <rb6502@users.noreply.github.com>2019-10-13 07:50:38 -0400
commit0837e7451a84f95c29dbdb9bd6b8b931fee1635d (patch)
tree626bcbd250a7fbebdf5958a288d2f438d4f9fb5a /src/osd
parentc913ccb59d713ce0b91135520719ac5385e54358 (diff)
WIP: sync bgfx, bx and bimg with latest upstream (#5723)
* Sync with bgfx upstream revision b91d0b6 * Sync with bx upstream revision d60912b * Sync with bimg upstream revision bd81f60 * Add astc-codec decoder * Rename VertexDecl to VertexLayout * Rename UniformType enum Int1 to Sampler. * Add NVN stub * Fix unused-const-variable error on macOS * Drop redundant explicit language parameters buildoptions_cpp are only applied to c++ files and buildoptions_objcpp are only applied to objective c++ files. As such, hardcoding -x offers no benefit while preventing overrides (such as one needed by 3rdparty/bgfx/src/renderer_vk.cpp on macOS) from working. * Re-introduce -x c++ in places where C code is compiled as C++ to prevent clang from throwing a warning * Build bgfx as Objective-C++ on macOS It is needed due to included headers * Enable Direct3D12 and Vulkan bgfx rendering backends * Enable building of spirv shaders * Properly escape /c in cmd call * Comment out dx12 bgfx renderer * Honor VERBOSE setting during shaders build * Only invert hlsl shader XYZ_TO_sRGB matrix for opengl * Add spirv shaders * OpenGL ES needs transposed matrix too * Metal needs transposed matrix as well
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc9
-rw-r--r--src/osd/modules/render/bgfx/shaders/makefile26
-rw-r--r--src/osd/modules/render/bgfx/shaders/shader.mk8
-rw-r--r--src/osd/modules/render/bgfx/uniform.cpp6
-rw-r--r--src/osd/modules/render/bgfx/uniformreader.cpp2
-rw-r--r--src/osd/modules/render/bgfx/vertex.h2
-rw-r--r--src/osd/modules/render/drawbgfx.cpp11
7 files changed, 42 insertions, 22 deletions
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc
index 51bb14676d3..c0d8ba07ac7 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc
@@ -22,11 +22,20 @@ void main()
vec4 cin = texture2D(s_tex, v_texcoord0);
vec4 cout = vec4(0.0, 0.0, 0.0, cin.a);
mat3 xy = mat3(u_chroma_a.xyz, u_chroma_b.xyz, u_chroma_c.xyz);
+
+#ifdef TRANSPOSED_XYZ_TO_sRGB
const mat3 XYZ_TO_sRGB = mat3(
3.2406, -0.9689, 0.0557,
-1.5372, 1.8758, -0.2040,
-0.4986, 0.0415, 1.0570
);
+#else
+ const mat3 XYZ_TO_sRGB = mat3(
+ 3.2406, -1.5372, -0.4986,
+ -0.9689, 1.8758, 0.0415,
+ 0.0557, -0.2040, 1.0570
+ );
+#endif
for (int i = 0; i < 3; ++i) {
float Y = u_y_gain[i] * cin[i];
diff --git a/src/osd/modules/render/bgfx/shaders/makefile b/src/osd/modules/render/bgfx/shaders/makefile
index 1ca45471b9b..7a058e7810f 100644
--- a/src/osd/modules/render/bgfx/shaders/makefile
+++ b/src/osd/modules/render/bgfx/shaders/makefile
@@ -15,22 +15,24 @@ endif
$(SUBDIRS):
@echo $@
ifeq ($(OS),windows)
- @make -s --no-print-directory TARGET=0 SHADERS_DIR=$@/ clean all
- @make -s --no-print-directory TARGET=1 SHADERS_DIR=$@/ clean all
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=0 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=1 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
endif
- @make -s --no-print-directory TARGET=2 SHADERS_DIR=$@/ clean all
- @make -s --no-print-directory TARGET=3 SHADERS_DIR=$@/ clean all
- @make -s --no-print-directory TARGET=4 SHADERS_DIR=$@/ clean all
- @make -s --no-print-directory TARGET=5 SHADERS_DIR=$@/ clean all
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=2 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=3 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=4 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=5 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=7 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
main:
ifeq ($(OS),windows)
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=0 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=1 clean all SILENT="$(SILENT)"
endif
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=2 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=3 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=4 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=5 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) -s --no-print-directory TARGET=7 clean all SILENT="$(SILENT)"
.PHONY: main rebuild $(SUBDIRS)
diff --git a/src/osd/modules/render/bgfx/shaders/shader.mk b/src/osd/modules/render/bgfx/shaders/shader.mk
index e7db3cdc242..b9cf2f47cef 100644
--- a/src/osd/modules/render/bgfx/shaders/shader.mk
+++ b/src/osd/modules/render/bgfx/shaders/shader.mk
@@ -43,24 +43,24 @@ SHADER_PATH=shaders/dx11/$(SHADERS_DIR)
else
ifeq ($(TARGET), 2)
VS_FLAGS=--platform nacl
-FS_FLAGS=--platform nacl
+FS_FLAGS=--platform nacl --define TRANSPOSED_XYZ_TO_sRGB
SHADER_PATH=shaders/essl/$(SHADERS_DIR)
else
ifeq ($(TARGET), 3)
VS_FLAGS=--platform android
-FS_FLAGS=--platform android
+FS_FLAGS=--platform android --define TRANSPOSED_XYZ_TO_sRGB
CS_FLAGS=--platform android
SHADER_PATH=shaders/essl/$(SHADERS_DIR)
else
ifeq ($(TARGET), 4)
VS_FLAGS=--platform linux -p 120
-FS_FLAGS=--platform linux -p 120
+FS_FLAGS=--platform linux -p 120 --define TRANSPOSED_XYZ_TO_sRGB
CS_FLAGS=--platform linux -p 430
SHADER_PATH=shaders/glsl/$(SHADERS_DIR)
else
ifeq ($(TARGET), 5)
VS_FLAGS=--platform osx -p metal
-FS_FLAGS=--platform osx -p metal
+FS_FLAGS=--platform osx -p metal --define TRANSPOSED_XYZ_TO_sRGB
CS_FLAGS=--platform osx -p metal
SHADER_PATH=shaders/metal/$(SHADERS_DIR)
else
diff --git a/src/osd/modules/render/bgfx/uniform.cpp b/src/osd/modules/render/bgfx/uniform.cpp
index ef33c11f128..dc81475ad59 100644
--- a/src/osd/modules/render/bgfx/uniform.cpp
+++ b/src/osd/modules/render/bgfx/uniform.cpp
@@ -29,7 +29,7 @@ bgfx_uniform::~bgfx_uniform()
void bgfx_uniform::upload()
{
- if (m_type != bgfx::UniformType::Int1)
+ if (m_type != bgfx::UniformType::Sampler)
{
bgfx::setUniform(m_handle, m_data);
}
@@ -42,7 +42,7 @@ bgfx_uniform* bgfx_uniform::set(float* value)
bgfx_uniform* bgfx_uniform::set_int(int value)
{
- return set(&value, get_size_for_type(bgfx::UniformType::Int1));
+ return set(&value, get_size_for_type(bgfx::UniformType::Sampler));
}
bgfx_uniform* bgfx_uniform::set_mat3(float* value)
@@ -69,7 +69,7 @@ size_t bgfx_uniform::get_size_for_type(bgfx::UniformType::Enum type)
case bgfx::UniformType::Vec4:
return sizeof(float) * 4;
- case bgfx::UniformType::Int1:
+ case bgfx::UniformType::Sampler:
return sizeof(int);
case bgfx::UniformType::Mat3:
diff --git a/src/osd/modules/render/bgfx/uniformreader.cpp b/src/osd/modules/render/bgfx/uniformreader.cpp
index 3e3cb5db318..c97ca484e48 100644
--- a/src/osd/modules/render/bgfx/uniformreader.cpp
+++ b/src/osd/modules/render/bgfx/uniformreader.cpp
@@ -11,7 +11,7 @@
#include "uniform.h"
const uniform_reader::string_to_enum uniform_reader::TYPE_NAMES[uniform_reader::TYPE_COUNT] = {
- { "int", bgfx::UniformType::Int1 },
+ { "int", bgfx::UniformType::Sampler },
{ "vec4", bgfx::UniformType::Vec4 },
{ "mat3", bgfx::UniformType::Mat3 },
{ "mat4", bgfx::UniformType::Mat4 }
diff --git a/src/osd/modules/render/bgfx/vertex.h b/src/osd/modules/render/bgfx/vertex.h
index 32b3c36064f..2036296a9d0 100644
--- a/src/osd/modules/render/bgfx/vertex.h
+++ b/src/osd/modules/render/bgfx/vertex.h
@@ -31,7 +31,7 @@ struct ScreenVertex
.end();
}
- static bgfx::VertexDecl ms_decl;
+ static bgfx::VertexLayout ms_decl;
};
#endif // __DRAWBGFX_VERTEX__
diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp
index 3c15bc3cf96..87fbdd21d3a 100644
--- a/src/osd/modules/render/drawbgfx.cpp
+++ b/src/osd/modules/render/drawbgfx.cpp
@@ -278,6 +278,11 @@ int renderer_bgfx::create()
{
init.type = bgfx::RendererType::Direct3D11;
}
+// Throws exception on exit
+// else if (backend == "dx12" || backend == "d3d12")
+// {
+// init.type = bgfx::RendererType::Direct3D12;
+// }
else if (backend == "gles")
{
init.type = bgfx::RendererType::OpenGLES;
@@ -286,6 +291,10 @@ int renderer_bgfx::create()
{
init.type = bgfx::RendererType::OpenGL;
}
+ else if (backend == "vulkan")
+ {
+ init.type = bgfx::RendererType::Vulkan;
+ }
else if (backend == "metal")
{
init.type = bgfx::RendererType::Metal;
@@ -441,7 +450,7 @@ int renderer_bgfx::xy_to_render_target(int x, int y, int *xt, int *yt)
// drawbgfx_window_draw
//============================================================
-bgfx::VertexDecl ScreenVertex::ms_decl;
+bgfx::VertexLayout ScreenVertex::ms_decl;
void renderer_bgfx::put_packed_quad(render_primitive *prim, uint32_t hash, ScreenVertex* vertices)
{