mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 13:11:19 +01:00
Tighter RHI integration, extra build options
Diffs= f161bf4679 Tighter RHI integration, extra build options (#9149) Co-authored-by: Jonathon Copeland <jcopela4@gmail.com>
This commit is contained in:
committed by
Chris Dalton
parent
695dfdaffc
commit
9b209b75f8
@@ -1 +1 @@
|
||||
57d81702cb268580c8fbbb23084aa8a069982a0e
|
||||
f161bf467917880176e3ded8ca0571879a76ff94
|
||||
|
||||
@@ -4,11 +4,7 @@ if _OPTIONS['no-rive-decoders'] then
|
||||
return
|
||||
end
|
||||
|
||||
rive = path.getabsolute('../')
|
||||
|
||||
dofile(rive .. '/dependencies/premake5_libpng_v2.lua')
|
||||
dofile(rive .. '/dependencies/premake5_libjpeg_v2.lua')
|
||||
dofile(rive .. '/dependencies/premake5_libwebp_v2.lua')
|
||||
local rive = path.getabsolute('../')
|
||||
|
||||
newoption({
|
||||
trigger = 'no_rive_png',
|
||||
@@ -20,6 +16,16 @@ newoption({
|
||||
description = 'don\'t build jpeg support into the rive_decoders library (built-in jpeg decoding will fail)',
|
||||
})
|
||||
|
||||
if not _OPTIONS["no_rive_png"] then
|
||||
dofile(rive .. '/dependencies/premake5_libpng_v2.lua')
|
||||
end
|
||||
|
||||
if not _OPTIONS["no_rive_jpeg"] then
|
||||
dofile(rive .. '/dependencies/premake5_libjpeg_v2.lua')
|
||||
end
|
||||
|
||||
dofile(rive .. '/dependencies/premake5_libwebp_v2.lua')
|
||||
|
||||
project('rive_decoders')
|
||||
do
|
||||
dependson('libwebp')
|
||||
@@ -29,8 +35,6 @@ do
|
||||
includedirs({
|
||||
'include',
|
||||
'../include',
|
||||
libpng,
|
||||
libjpeg,
|
||||
libwebp .. '/src',
|
||||
'%{cfg.targetdir}/include/libpng',
|
||||
})
|
||||
@@ -72,7 +76,21 @@ do
|
||||
})
|
||||
end
|
||||
|
||||
filter({ 'system:not macosx', 'system:not ios', 'options:not no_rive_png' })
|
||||
filter({'options:not no_rive_png'})
|
||||
do
|
||||
includedirs({
|
||||
libpng
|
||||
})
|
||||
end
|
||||
|
||||
filter({'options:not no_rive_jpeg'})
|
||||
do
|
||||
includedirs({
|
||||
libjpeg
|
||||
})
|
||||
end
|
||||
|
||||
filter({ 'system:not macosx', 'system:not ios', 'options:not no_rive_png' })
|
||||
do
|
||||
dependson('zlib', 'libpng')
|
||||
defines({ 'RIVE_PNG' })
|
||||
|
||||
17
dependencies/premake5_harfbuzz_v2.lua
vendored
17
dependencies/premake5_harfbuzz_v2.lua
vendored
@@ -8,6 +8,11 @@ newoption({
|
||||
description = 'don\'t rename harfbuzz symbols',
|
||||
})
|
||||
|
||||
newoption({
|
||||
trigger = 'harfbuzz_getenv_no_op',
|
||||
description = 'force include the header to no add no op implementation for getenv',
|
||||
})
|
||||
|
||||
project('rive_harfbuzz')
|
||||
do
|
||||
kind('StaticLib')
|
||||
@@ -276,6 +281,18 @@ do
|
||||
forceincludes({ 'rive_harfbuzz_renames.h' })
|
||||
end
|
||||
|
||||
filter({ 'options:harfbuzz_getenv_no_op', 'files:**/src/hb-common.cc or **/src/hb-shaper.cc', 'options:no-harfbuzz-renames'})
|
||||
do
|
||||
includedirs({ './' })
|
||||
forceincludes({ 'rive_harfbuzz_overrides.h'})
|
||||
end
|
||||
|
||||
filter({ 'options:harfbuzz_getenv_no_op', 'files:**/src/hb-common.cc or **/src/hb-shaper.cc', 'options:not no-harfbuzz-renames'})
|
||||
do
|
||||
includedirs({ './' })
|
||||
forceincludes({ 'rive_harfbuzz_overrides.h', 'rive_harfbuzz_renames.h' })
|
||||
end
|
||||
|
||||
filter('system:macosx or system:ios')
|
||||
do
|
||||
defines({ 'HAVE_CORETEXT' })
|
||||
|
||||
1
dependencies/rive_harfbuzz_overrides.h
vendored
Normal file
1
dependencies/rive_harfbuzz_overrides.h
vendored
Normal file
@@ -0,0 +1 @@
|
||||
char* getenv(const char* _) { return nullptr; }
|
||||
@@ -49,6 +49,8 @@
|
||||
#define RIVE_BUILD_FOR_OSX
|
||||
#endif
|
||||
|
||||
#define RIVE_NO_STD_SYSTEM
|
||||
|
||||
#endif
|
||||
|
||||
// We really like these headers, so we include them all the time.
|
||||
|
||||
@@ -62,6 +62,11 @@ end
|
||||
|
||||
filter({})
|
||||
|
||||
newoption({
|
||||
trigger = 'no_gl',
|
||||
description = 'do not compile in support for opengl',
|
||||
})
|
||||
|
||||
-- Minify and compile PLS shaders offline.
|
||||
local nproc
|
||||
if os.host() == 'windows' then
|
||||
@@ -193,7 +198,7 @@ do
|
||||
})
|
||||
end
|
||||
|
||||
filter({ 'system:not ios' })
|
||||
filter({ 'system:not ios', 'options:not no_gl' })
|
||||
do
|
||||
files({
|
||||
'src/gl/gl_state.cpp',
|
||||
|
||||
@@ -25,7 +25,9 @@ static size_t load_bytecode_file_into_buffer(std::ifstream& shaderBytecodeFile,
|
||||
char* bytecodeAllocation)
|
||||
{
|
||||
// Read entire file into buffer
|
||||
shaderBytecodeFile.read(bytecodeAllocation, fileSize);
|
||||
shaderBytecodeFile.read(
|
||||
bytecodeAllocation,
|
||||
rive::math::lossless_numeric_cast<std::streamsize>(fileSize));
|
||||
const size_t numActualBytesRead = shaderBytecodeFile.gcount();
|
||||
if (shaderBytecodeFile.good() && numActualBytesRead == fileSize)
|
||||
{
|
||||
|
||||
@@ -531,7 +531,7 @@ INLINE bool unpack_tessellated_path_vertex(float4 patchVertexData,
|
||||
|
||||
// Extend the vertex by half the width of the AA ramp.
|
||||
float2 vertexOffset =
|
||||
MUL(norm, strokeRadius + aaRadius); // Bloat stroke width for AA.
|
||||
norm * (strokeRadius + aaRadius); // Bloat stroke width for AA.
|
||||
|
||||
#ifndef @RENDER_MODE_MSAA
|
||||
// Calculate the AA distance to both the outset and inset edges of the
|
||||
|
||||
@@ -52,13 +52,21 @@ $typedef float3 packed_float3;
|
||||
|
||||
#ifdef @ENABLE_MIN_16_PRECISION
|
||||
|
||||
#if COMPILER_HLSL || COMPILER_VULKAN
|
||||
|
||||
$typedef $min16uint ushort;
|
||||
|
||||
#endif // COMPILER_HLSL
|
||||
|
||||
#else
|
||||
|
||||
#if COMPILER_HLSL || COMPILER_VULKAN
|
||||
|
||||
$typedef $uint ushort;
|
||||
|
||||
#endif
|
||||
#endif // COMPILER_HLSL
|
||||
|
||||
#endif // ENABLE_MIN_16_PRECISION
|
||||
|
||||
#define SPLAT(A, B) A##B
|
||||
|
||||
@@ -117,7 +125,7 @@ $typedef $uint ushort;
|
||||
|
||||
#define TEXTURE_RGBA32UI(SET, IDX, NAME) uniform $Texture2D<uint4> NAME
|
||||
#define TEXTURE_RGBA32F(SET, IDX, NAME) uniform $Texture2D<float4> NAME
|
||||
#define TEXTURE_RGBA8(SET, IDX, NAME) uniform $Texture2D<$unorm float4> NAME
|
||||
#define TEXTURE_RGBA8(SET, IDX, NAME) uniform $Texture2D<UNORM half4> NAME
|
||||
#define TEXTURE_R16F(SET, IDX, NAME) uniform $Texture2D<half> NAME
|
||||
#define TEXTURE_R16F_1D_ARRAY(SET, IDX, NAME) uniform $Texture2DArray<half> NAME
|
||||
#define SAMPLED_R16F_REF(NAME, SAMPLER_NAME) \
|
||||
@@ -159,7 +167,7 @@ $typedef $uint ushort;
|
||||
|
||||
#define PLS_BLOCK_BEGIN
|
||||
#ifdef @ENABLE_TYPED_UAV_LOAD_STORE
|
||||
#define PLS_DECL4F(IDX, NAME) uniform PLS_TEX2D<$unorm half4> NAME
|
||||
#define PLS_DECL4F(IDX, NAME) uniform PLS_TEX2D<UNORM half4> NAME
|
||||
#else
|
||||
#define PLS_DECL4F(IDX, NAME) uniform PLS_TEX2D<uint> NAME
|
||||
#endif
|
||||
@@ -257,8 +265,10 @@ INLINE uint pls_atomic_add(PLS_TEX2D<uint> plane, int2 _plsCoord, uint x)
|
||||
#define PLS_CONTEXT_DECL , int2 _plsCoord
|
||||
#define PLS_CONTEXT_UNPACK , _plsCoord
|
||||
|
||||
#define PLS_MAIN(NAME) [$earlydepthstencil] void NAME(Varyings _varyings) { \
|
||||
float2 _fragCoord = _varyings._pos.xy;\
|
||||
#define PLS_MAIN(NAME) \
|
||||
EARLYDEPTHSTENCIL void NAME(Varyings _varyings) \
|
||||
{ \
|
||||
float2 _fragCoord = _varyings._pos.xy; \
|
||||
int2 _plsCoord = int2(floor(_fragCoord));
|
||||
|
||||
#define PLS_MAIN_WITH_IMAGE_UNIFORMS(NAME) PLS_MAIN(NAME)
|
||||
@@ -266,7 +276,7 @@ INLINE uint pls_atomic_add(PLS_TEX2D<uint> plane, int2 _plsCoord, uint x)
|
||||
#define EMIT_PLS }
|
||||
|
||||
#define PLS_FRAG_COLOR_MAIN(NAME) \
|
||||
[$earlydepthstencil] half4 NAME(Varyings _varyings) : $SV_Target \
|
||||
EARLYDEPTHSTENCIL half4 NAME(Varyings _varyings) : $SV_Target \
|
||||
{ \
|
||||
float2 _fragCoord = _varyings._pos.xy; \
|
||||
int2 _plsCoord = int2(floor(_fragCoord)); \
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
#include "Generated/constants.minified.ush"
|
||||
#include "Generated/common.minified.ush"
|
||||
#include "Generated/draw_path_common.minified.ush"
|
||||
#include "Generated/draw_atlas.minified.ush"
|
||||
#include "Generated/render_atlas.minified.ush"
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
#include "Generated/constants.minified.ush"
|
||||
#include "Generated/common.minified.ush"
|
||||
#include "Generated/draw_path_common.minified.ush"
|
||||
#include "Generated/draw_atlas.minified.ush"
|
||||
#include "Generated/render_atlas.minified.ush"
|
||||
|
||||
@@ -23,6 +23,7 @@ while :; do
|
||||
-u)
|
||||
TARGET="unreal"
|
||||
DEFAULT_BACKEND=rhi
|
||||
ARGS="$ARGS --no-rebuild --no-install"
|
||||
shift
|
||||
;;
|
||||
-i)
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef EXTERNAL_TCP_CLIENT_DEFINITION
|
||||
|
||||
std::unique_ptr<TCPClient> TCPClient::Connect(
|
||||
const char* serverAddress /*server:port*/)
|
||||
{
|
||||
@@ -206,3 +208,4 @@ std::string TCPClient::recvString()
|
||||
recvall(str.data(), length);
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,16 @@
|
||||
#include "png.h"
|
||||
#include "zlib.h"
|
||||
#include <vector>
|
||||
|
||||
#ifdef SYS_SIGNAL_H
|
||||
#include <sys/signal.h>
|
||||
const char* strsignal(int)
|
||||
{
|
||||
return "(strsignal) not suported on this platform";
|
||||
}
|
||||
#else
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
@@ -79,6 +88,7 @@ TestHarness& TestHarness::Instance()
|
||||
|
||||
TestHarness::TestHarness()
|
||||
{
|
||||
#ifndef NO_SIGNAL_FORWARD
|
||||
// Forward signals to the test harness.
|
||||
for (int i = 1; i <= SIGTERM; ++i)
|
||||
{
|
||||
@@ -88,6 +98,7 @@ TestHarness::TestHarness()
|
||||
// Check for if the app exits early (before calling
|
||||
// TestHarness::shutdown()).
|
||||
atexit(check_early_exit);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TestHarness::init(std::unique_ptr<TCPClient> tcpClient,
|
||||
@@ -126,12 +137,13 @@ void TestHarness::init(std::filesystem::path outputDir, size_t pngThreadCount)
|
||||
|
||||
void TestHarness::initStdioThread()
|
||||
{
|
||||
#ifndef NO_REDIRECT_OUTPUT
|
||||
|
||||
#ifndef _WIN32
|
||||
// Make stdout & stderr line buffered. (This is not supported on Windows.)
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
#endif
|
||||
|
||||
// Pipe stdout and sterr back to the server.
|
||||
m_savedStdout = dup(1);
|
||||
m_savedStderr = dup(2);
|
||||
@@ -139,6 +151,7 @@ void TestHarness::initStdioThread()
|
||||
dup2(m_stdioPipe[1], 1);
|
||||
dup2(m_stdioPipe[1], 2);
|
||||
m_stdioThread = std::thread(MonitorStdIOThread, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TestHarness::monitorStdIOThread()
|
||||
@@ -427,6 +440,7 @@ void TestHarness::shutdown()
|
||||
|
||||
void TestHarness::shutdownStdioThread()
|
||||
{
|
||||
#ifndef NO_REDIRECT_OUTPUT
|
||||
if (m_savedStdout != 0 || m_savedStderr != 0)
|
||||
{
|
||||
// Restore stdout and stderr.
|
||||
@@ -442,6 +456,7 @@ void TestHarness::shutdownStdioThread()
|
||||
close(m_stdioPipe[0]);
|
||||
m_stdioPipe = {0, 0};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void TestHarness::shutdownInputPumpThread()
|
||||
|
||||
@@ -142,6 +142,7 @@ TestingWindow::Backend TestingWindow::ParseBackend(const char* name,
|
||||
|
||||
static void set_environment_variable(const char* name, const char* value)
|
||||
{
|
||||
#ifndef PLATFORM_NO_ENV_API
|
||||
if (const char* existingValue = getenv(name))
|
||||
{
|
||||
printf("warning: %s=%s already set. Overriding with %s=%s\n",
|
||||
@@ -155,6 +156,7 @@ static void set_environment_variable(const char* name, const char* value)
|
||||
#else
|
||||
setenv(name, value, /*overwrite=*/true);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TestingWindow* TestingWindow::Init(Backend backend,
|
||||
|
||||
@@ -309,7 +309,7 @@ int main(int argc, const char* argv[])
|
||||
if (hotloadShaders)
|
||||
{
|
||||
hotloadShaders = false;
|
||||
#ifndef RIVE_BUILD_FOR_IOS
|
||||
#ifndef RIVE_NO_STD_SYSTEM
|
||||
std::system("sh rebuild_shaders.sh /tmp/rive");
|
||||
TestingWindow::Get()->hotloadShaders();
|
||||
#endif
|
||||
|
||||
@@ -165,13 +165,19 @@ function rive_tools_project(name, project_kind)
|
||||
'rive',
|
||||
'libpng',
|
||||
'zlib',
|
||||
'libjpeg',
|
||||
'libwebp',
|
||||
'rive_yoga',
|
||||
'rive_harfbuzz',
|
||||
'rive_sheenbidi',
|
||||
})
|
||||
|
||||
filter({ 'kind:ConsoleApp or SharedLib or WindowedApp', 'options:not no_rive_jpeg' })
|
||||
do
|
||||
links({
|
||||
'libjpeg',
|
||||
})
|
||||
end
|
||||
|
||||
if ndk then
|
||||
relative_ndk = ndk
|
||||
if string.sub(ndk, 1, 1) == '/' then
|
||||
@@ -274,11 +280,10 @@ do
|
||||
RIVE_PLS_DIR .. '/path_fiddle/fiddle_context_vulkan.cpp',
|
||||
RIVE_PLS_DIR .. '/path_fiddle/fiddle_context_dawn.cpp',
|
||||
})
|
||||
|
||||
filter({ 'options:for_unreal' })
|
||||
|
||||
filter({ 'options:for_unreal'})
|
||||
do
|
||||
defines({ 'RIVE_UNREAL', 'RIVE_TOOLS_NO_GLFW', 'RIVE_TOOLS_NO_GL' })
|
||||
cppdialect('C++20')
|
||||
end
|
||||
|
||||
filter({ 'toolset:not msc' })
|
||||
|
||||
Reference in New Issue
Block a user