Skip to content

Commit ba6906f

Browse files
committed
dawn: fixes to reconstructPosition, and line rendering
1 parent 528721a commit ba6906f

File tree

14 files changed

+56
-24
lines changed

14 files changed

+56
-24
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ endif()
1818
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1919
include(cage_all)
2020

21+
option(cage_faster_debug "enable some optimizations to improve performance in debug builds" ON)
22+
option(cage_faster_release "enable more aggressive inlining in release builds" OFF)
23+
option(cage_assert_in_release_enabled "enable runtime asserts in non-debug builds" OFF)
24+
option(cage_validate_graphics "enable runtime validation in webgpu/dawn" ON)
25+
option(cage_profiling_enabled "enable compiling-in instructions for profiling" ON)
26+
option(cage_use_steam_sockets "include Game Networking Sockets library by Valve/Steam" OFF)
27+
2128
if(CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
2229
cage_default_init() # standalone build
2330
else()

cmake/cage_build_configuration.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ macro(cage_build_configuration)
5555
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd26451") # Arithmetic overflow: Using operator ___ on a 4 byte value and then casting the result to a 8 byte value.
5656

5757
# optionally improve runtime performance in debug builds (basic inlining)
58-
option(cage_faster_debug "enable some optimizations to improve performance in debug builds" ON)
5958
if(cage_faster_debug)
6059
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
6160
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
@@ -64,7 +63,6 @@ macro(cage_build_configuration)
6463
endif()
6564

6665
# optionally improve runtime performance in release builds (more aggressive inlining)
67-
option(cage_faster_release "enable more aggressive inlining in release builds" OFF)
6866
if(cage_faster_release)
6967
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
7068
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11

2+
if(NOT DEFINED egac_fetch_cage_externals_done) # INTERNAL implies FORCE
3+
set(egac_fetch_cage_externals_done OFF CACHE INTERNAL "")
4+
endif()
5+
26
function(cage_fetch_cage_externals)
7+
if(egac_fetch_cage_externals_done)
8+
return()
9+
endif()
310
execute_process(COMMAND "bash" "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../submodules.sh" WORKING_DIRECTORY "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/.." COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)
11+
set(egac_fetch_cage_externals_done ON CACHE INTERNAL "" FORCE)
412
endfunction(cage_fetch_cage_externals)
513

data/cage/shaders/engine/decal.glsl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ void main()
1313

1414

1515
$include fragment.glsl
16-
1716
$include ../functions/reconstructPosition.glsl
1817

1918
void main()
2019
{
20+
updateNormal();
21+
Material material = loadMaterial();
2122
vec3 prevPos = reconstructPosition(texDepth, uniProjection.vpInv, uniViewport.viewport);
2223
if (length(varPosition - prevPos) > 0.05)
2324
discard;
24-
updateNormal();
25-
Material material = loadMaterial();
2625
#ifdef CutOut
2726
if (material.opacity < 0.5)
2827
discard;
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11

22
vec3 reconstructPosition(sampler2D texDepth, mat4 vpInv, vec4 viewport)
33
{
4-
float depth = texelFetch(texDepth, ivec2(gl_FragCoord.xy), 0).x * 2 - 1;
5-
vec4 pos = vec4((gl_FragCoord.xy - viewport.xy) / viewport.zw * 2 - 1, depth, 1);
4+
float depth = texelFetch(texDepth, ivec2(gl_FragCoord.xy), 0).x;
5+
vec4 pos = vec4(gl_FragCoord.xy / viewport.zw * 2 - 1, depth, 1);
6+
pos.y = -pos.y;
67
pos = vpInv * pos;
78
return pos.xyz / pos.w;
89
}

externals/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ macro(cage_heavily_optimized)
8888
endif()
8989
endmacro(cage_heavily_optimized)
9090

91-
option(cage_use_steam_sockets "include Game Networking Sockets library by Valve/Steam" OFF)
92-
9391
message(STATUS "----------------------------------------------------------------")
9492
message(STATUS "starting cage external subdirectories")
9593
message(STATUS "----------------------------------------------------------------")

externals/dawn/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ set(DAWN_ENABLE_WEBGPU_ON_WEBGPU OFF CACHE INTERNAL "Enable compilation of the W
2424
set(DAWN_ENABLE_DESKTOP_GL OFF CACHE INTERNAL "Enable compilation of the OpenGL backend" FORCE)
2525
set(DAWN_ENABLE_OPENGLES OFF CACHE INTERNAL "Enable compilation of the OpenGL ES backend" FORCE)
2626
set(DAWN_ENABLE_VULKAN ${vulkan} CACHE INTERNAL "Enable compilation of the Vulkan backend" FORCE)
27+
set(DAWN_ENABLE_SPIRV_VALIDATION ${cage_validate_graphics} CACHE INTERNAL "Enable validation of SPIR-V" FORCE)
2728
set(DAWN_FORCE_SYSTEM_COMPONENT_LOAD ON CACHE INTERNAL "Allow system component fallback" FORCE)
2829
set(DAWN_USE_WAYLAND OFF CACHE INTERNAL "Enable support for Wayland surface" FORCE)
2930
set(DAWN_USE_X11 OFF CACHE INTERNAL "Enable support for X11 surface" FORCE)
@@ -48,11 +49,15 @@ set(TINT_ENABLE_INSTALL OFF CACHE INTERNAL "Enable install step for Tint librari
4849
set(TINT_BUILD_CMD_TOOLS OFF CACHE INTERNAL "Build the Tint command line tools" FORCE)
4950
set(TINT_BUILD_IR_BINARY OFF CACHE INTERNAL "Build IR binary format support" FORCE)
5051
set(TINT_BUILD_TESTS OFF CACHE INTERNAL "Build tests" FORCE)
51-
set(TINT_ENABLE_IR_VALIDATION ON CACHE INTERNAL "Enable IR validation for backend codegen" FORCE)
52+
set(TINT_ENABLE_IR_VALIDATION ${cage_validate_graphics} CACHE INTERNAL "Enable IR validation for backend codegen" FORCE)
5253

5354
unset(metal)
5455
unset(vulkan)
5556

57+
if(NOT CMAKE_BUILD_TYPE)
58+
set(CMAKE_BUILD_TYPE "RELEASE")
59+
endif()
60+
5661
# replace constants header
5762
set(constants_path "${CMAKE_CURRENT_LIST_DIR}/dawn/src/dawn/common/Constants.h")
5863
include_directories("${CMAKE_CURRENT_BINARY_DIR}/patches")

sources/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ endif()
4646
target_compile_definitions(cage-core PUBLIC "$<$<CONFIG:DEBUG>:CAGE_DEBUG>")
4747
target_compile_definitions(cage-core PUBLIC "$<$<CONFIG:DEBUG>:CAGE_DEBUG_BOOL=true>")
4848
target_compile_definitions(cage-core PUBLIC "$<$<NOT:$<CONFIG:DEBUG>>:CAGE_DEBUG_BOOL=false>")
49-
option(cage_assert_in_release_enabled "enable runtime asserts in non-debug builds" OFF)
5049
if(cage_assert_in_release_enabled)
5150
target_compile_definitions(cage-core PUBLIC "CAGE_ASSERT_ENABLED")
5251
else()
5352
target_compile_definitions(cage-core PUBLIC "$<$<CONFIG:DEBUG>:CAGE_ASSERT_ENABLED>")
5453
endif()
55-
option(cage_profiling_enabled "enable compiling-in instructions for profiling" ON)
5654
if(cage_profiling_enabled)
5755
target_compile_definitions(cage-core PUBLIC CAGE_PROFILING_ENABLED)
5856
cage_embed_file(cage-core "profiling.htm" profiling_htm)

sources/asset-processor/shader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ void processShader()
518518
{
519519
const uint32 cdc = toUint32(defines["customDataCount"]);
520520
CAGE_LOG(SeverityEnum::Info, "assetProcessor", Stringizer() + "custom data count: " + cdc);
521+
if ((cdc % 4) != 0)
522+
CAGE_THROW_ERROR(Exception, "customDataCount must be divisible by 4");
521523
header.customDataCount = cdc;
522524
}
523525
header.variantsCount = variants.size();

sources/include/cage-engine/graphicsEncoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace cage
8080
public:
8181
void nextPass(const PassConfig &config);
8282

83-
//void scissors(Vec2i origin, Vec2i size);
83+
void scissors(Vec2i origin, Vec2i size);
8484
void draw(const DrawConfig &config);
8585
void execute(wgpu::RenderBundle bundle);
8686

0 commit comments

Comments
 (0)