[client] network: fix ANGLE decoder synchronization

The dequant shader returned before workgroup barriers for missing
blocks. Mask those blocks to zero so ANGLE's D3D compiler accepts the
shader while every invocation reaches each barrier.

The vcpkg ANGLE build also omitted upstream shared-context locking.
Enable both locking definitions so decode dispatches cannot race the
render thread through ANGLE's shared D3D11 state manager.
This commit is contained in:
Geoffrey McRae
2026-10-03 10:41:57 +10:00
parent f6c32c2c1e
commit 7f63dc986e
3 changed files with 28 additions and 14 deletions

View File

@@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 3.20)
project(looking-glass-client C CXX)
if(WIN32)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/cmake/vcpkg-triplets/x64-windows-lg.cmake")
endif()
get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE)
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)

View File

@@ -7,3 +7,13 @@ if(PORT STREQUAL "openssl")
else()
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()
if(PORT STREQUAL "angle")
# ANGLE's D3D state cache is shared across contexts. Serialize access and
# dirty cached state whenever calls switch between shared contexts.
string(CONCAT ANGLE_CONTEXT_FLAGS
" /DANGLE_ENABLE_SHARE_CONTEXT_LOCK=1"
" /DANGLE_FORCE_CONTEXT_CHECK_EVERY_CALL=1")
string(APPEND VCPKG_C_FLAGS "${ANGLE_CONTEXT_FLAGS}")
string(APPEND VCPKG_CXX_FLAGS "${ANGLE_CONTEXT_FLAGS}")
endif()

View File

@@ -87,22 +87,21 @@ static const char NETWORK_VIDEO_DEQUANT_SHADER_0[] =
" }\n"
"}\n"
"void main() {\n"
" uint localIndex = gl_LocalInvocationIndex;\n"
" int blockIndex = blockOffset + int(gl_WorkGroupID.y) * blockStride +\n"
" uint localIndex = gl_LocalInvocationIndex;\n"
" int blockIndex = blockOffset + int(gl_WorkGroupID.y) * blockStride +\n"
" int(gl_WorkGroupID.x);\n"
" uint sourceWord = offsets[blockIndex];\n"
" uint subblock = bitfieldExtract(localIndex,0,3);\n"
" uint blockX = bitfieldExtract(localIndex,3,2);\n"
" uint blockY = bitfieldExtract(localIndex,5,2);\n"
" uint group = blockY * 4u + blockX;\n"
" ivec2 coord = ivec2(gl_WorkGroupID.xy) * 32 +\n"
" uint sourceWord = offsets[blockIndex];\n"
" uint blockPresent = uint(sourceWord != 0xffffffffu);\n"
" // Missing blocks must still reach every workgroup barrier.\n"
" sourceWord *= blockPresent;\n"
" uint subblock = bitfieldExtract(localIndex,0,3);\n"
" uint blockX = bitfieldExtract(localIndex,3,2);\n"
" uint blockY = bitfieldExtract(localIndex,5,2);\n"
" uint group = blockY * 4u + blockX;\n"
" ivec2 coord = ivec2(gl_WorkGroupID.xy) * 32 +\n"
" 8 * ivec2(blockX,blockY) + unswizzle8x8(subblock << 3u);\n"
" if (sourceWord == 0xffffffffu) {\n"
" storeValues(coord,mat2x4(vec4(0.0),vec4(0.0)));\n"
" return;\n"
" }\n"
" uint sourceByte = sourceWord * 4u;\n"
" uint ballot = payload[sourceWord] & 65535u;\n"
" uint ballot = (payload[sourceWord] & 65535u) * blockPresent;\n"
" if (localIndex == 0u) {\n"
" uint cursor = sourceByte + 8u + 3u * uint(bitCount(ballot));\n"
" for (uint index=0u; index<16u; ++index) {\n"
@@ -118,7 +117,7 @@ static const char NETWORK_VIDEO_DEQUANT_SHADER_0[] =
" cursor += uint(bitCount(low) + bitCount(high)) + 8u * qbits;\n"
" }\n"
" }\n"
" signOffset = cursor * 8u;\n"
" signOffset = cursor * 8u * blockPresent;\n"
" }\n"
" barrier();\n";