mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
Build / Source changes for NVRHI on SDL, source cleanup for clang C++17 std, initial macOS NVRHI implementation
This commit is contained in:
parent
e8f6900b3d
commit
86bcffdd00
30 changed files with 1539 additions and 274 deletions
|
@ -832,9 +832,9 @@ AM_clipMline
|
|||
TOP = 8
|
||||
};
|
||||
|
||||
register int outcode1 = 0;
|
||||
register int outcode2 = 0;
|
||||
register int outside;
|
||||
int outcode1 = 0;
|
||||
int outcode2 = 0;
|
||||
int outside;
|
||||
|
||||
fpoint_t tmp = { 0, 0 };
|
||||
int dx;
|
||||
|
@ -977,15 +977,15 @@ AM_drawFline
|
|||
( fline_t* fl,
|
||||
int color )
|
||||
{
|
||||
register int x;
|
||||
register int y;
|
||||
register int dx;
|
||||
register int dy;
|
||||
register int sx;
|
||||
register int sy;
|
||||
register int ax;
|
||||
register int ay;
|
||||
register int d;
|
||||
int x;
|
||||
int y;
|
||||
int dx;
|
||||
int dy;
|
||||
int sx;
|
||||
int sy;
|
||||
int ax;
|
||||
int ay;
|
||||
int d;
|
||||
|
||||
static int fuck = 0;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ option(SPIRV_SHADERC
|
|||
"Compile SPIR-V shader byte code using shaderc instead of using Glslang directly" OFF)
|
||||
|
||||
option(USE_MoltenVK
|
||||
"Use MoltenVK library directly instead of Vulkan loader on macOS" OFF)
|
||||
"Link directly to MoltenVK library instead of Vulkan loader on macOS" OFF)
|
||||
|
||||
option(ONATIVE
|
||||
"Optimize for the host CPU" OFF)
|
||||
|
@ -69,7 +69,7 @@ option(USE_DX12
|
|||
"Use DirectX 12" ON)
|
||||
|
||||
option(USE_NVRHI_VULKAN
|
||||
"Use Vulkan" ON)
|
||||
"Use Vulkan" OFF)
|
||||
|
||||
set(NVRHI_INSTALL OFF)
|
||||
|
||||
|
@ -101,6 +101,7 @@ endif()
|
|||
|
||||
if(UNIX)
|
||||
set(OPENAL ON)
|
||||
set(USE_DX12 OFF)
|
||||
|
||||
# SRS - Disable precompiled headers when cross-compiling on OSX, e.g. when creating universal binaries
|
||||
if((CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64" AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64" ) OR
|
||||
|
@ -110,12 +111,22 @@ if(UNIX)
|
|||
endif()
|
||||
|
||||
if(USE_VULKAN)
|
||||
SET(SDL2 ON)
|
||||
# SRS - handle legacy Vulkan backend first to support existing cmake scripts
|
||||
set(USE_NVRHI OFF)
|
||||
set(USE_NVRHI_VULKAN OFF)
|
||||
set(SDL2 ON)
|
||||
|
||||
# RB: disable precompiled headers on Linux with Vulkan because of error: POSIX thread support was disabled in PCH file but is currently enabled
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(USE_PRECOMPILED_HEADERS OFF)
|
||||
endif()
|
||||
elseif(USE_NVRHI_VULKAN)
|
||||
# SRS - for new NVRHI backend on linux/macOS
|
||||
set(USE_NVRHI ON)
|
||||
set(SDL2 ON)
|
||||
else()
|
||||
# SRS - for legacy OpenGL backend
|
||||
set(USE_NVRHI OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -154,15 +165,15 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|||
add_definitions(-Werror=format-security)
|
||||
add_definitions(-Werror=format)
|
||||
|
||||
# Compiler check (needs -std=c++14 flag)
|
||||
# Compiler check (needs -std=c++17 flag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
||||
if(COMPILER_SUPPORTS_CXX14)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
|
||||
if(COMPILER_SUPPORTS_CXX17)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
else()
|
||||
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
|
||||
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
|
||||
if(CPU_TYPE)
|
||||
|
@ -190,8 +201,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# add clang-specific settings for warnings (the second one make sure clang doesn't complain
|
||||
# about unknown -W flags, like -Wno-unused-but-set-variable)
|
||||
# SRS - Add -Wno-deprecated-register and -Wno-expansion-to-defined to list of warning settings
|
||||
add_definitions(-Wno-local-type-template-args -Wno-unknown-warning-option -Wno-inline-new-delete -Wno-switch-enum -Wno-deprecated-register -Wno-expansion-to-defined)
|
||||
# SRS - Add -Wno-expansion-to-defined to list of warning settings
|
||||
add_definitions(-Wno-local-type-template-args -Wno-unknown-warning-option -Wno-inline-new-delete -Wno-switch-enum -Wno-expansion-to-defined)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CROSSCOMPILING AND ONATIVE)
|
||||
|
@ -430,7 +441,7 @@ if(USE_VULKAN)
|
|||
if(APPLE)
|
||||
# SRS - Enable Beta extensions for VULKAN_SDK portability subset features on OSX
|
||||
add_definitions(-DVK_ENABLE_BETA_EXTENSIONS)
|
||||
# SRS - Optionally use MoltenVK headers/library for runtime config functions on OSX
|
||||
# SRS - Optionally link directly to MoltenVK headers/library for runtime config functions on OSX
|
||||
if(USE_MoltenVK)
|
||||
add_definitions(-DUSE_MoltenVK)
|
||||
include_directories($ENV{VULKAN_SDK}/../MoltenVK/include)
|
||||
|
@ -475,38 +486,7 @@ elseif(USE_NVRHI_VULKAN)
|
|||
if(APPLE)
|
||||
# SRS - Enable Beta extensions for VULKAN_SDK portability subset features on OSX
|
||||
add_definitions(-DVK_ENABLE_BETA_EXTENSIONS)
|
||||
# SRS - Optionally use MoltenVK headers/library for runtime config functions on OSX
|
||||
if(USE_MoltenVK)
|
||||
add_definitions(-DUSE_MoltenVK)
|
||||
include_directories($ENV{VULKAN_SDK}/../MoltenVK/include)
|
||||
set(Vulkan_LIBRARY $ENV{VULKAN_SDK}/../MoltenVK/dylib/macOS/libMoltenVK.dylib CACHE FILEPATH "Path to MoltenVK library." FORCE)
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Using Vulkan: " ${Vulkan_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Eric: For use with SDL2/Vulkan
|
||||
if(UNIX)
|
||||
# SRS - For UNIX-like target OSs use the generic SDL Vulkan platform
|
||||
add_definitions(-DUSE_NVRHI_SDL)
|
||||
elseif(WIN32)
|
||||
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)
|
||||
endif()
|
||||
# Use FindVulkan module added with CMAKE 3.7
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 3.7.0)
|
||||
message( STATUS "Using module to find Vulkan" )
|
||||
find_package(Vulkan)
|
||||
endif()
|
||||
|
||||
if(NOT Vulkan_FOUND)
|
||||
message(FATAL_ERROR "Could not find Vulkan library!")
|
||||
else()
|
||||
include_directories($ENV{VULKAN_SDK}/include)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
# SRS - Enable Beta extensions for VULKAN_SDK portability subset features on OSX
|
||||
add_definitions(-DVK_ENABLE_BETA_EXTENSIONS)
|
||||
# SRS - Optionally use MoltenVK headers/library for runtime config functions on OSX
|
||||
# SRS - Optionally link directly to MoltenVK headers/library for runtime config functions on OSX
|
||||
if(USE_MoltenVK)
|
||||
add_definitions(-DUSE_MoltenVK)
|
||||
include_directories($ENV{VULKAN_SDK}/../MoltenVK/include)
|
||||
|
@ -572,6 +552,11 @@ if(USE_NVRHI)
|
|||
endif()
|
||||
|
||||
include_directories(${NVRHI_DIR}/include)
|
||||
else()
|
||||
# SRS - This may be needed for legacy backends since common code now uses nvrhi - TBD
|
||||
#set(NVRHI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/nvrhi)
|
||||
#add_subdirectory(${NVRHI_DIR})
|
||||
#include_directories(${NVRHI_DIR}/include)
|
||||
endif(USE_NVRHI)
|
||||
|
||||
if(USE_SYSTEM_RAPIDJSON)
|
||||
|
@ -1209,13 +1194,21 @@ file(GLOB SDL_SOURCES sys/sdl/*.cpp)
|
|||
|
||||
# Eric: Utilize either the Vulkan or GL implementation of SDL
|
||||
if(UNIX)
|
||||
if(USE_VULKAN OR USE_NVRHI)
|
||||
if(USE_VULKAN OR USE_NVRHI_VULKAN)
|
||||
get_filename_component(sdl_glimp_cpp_full_path ${CMAKE_CURRENT_SOURCE_DIR}/sys/sdl/sdl_glimp.cpp ABSOLUTE)
|
||||
list(REMOVE_ITEM SDL_SOURCES "${sdl_glimp_cpp_full_path}")
|
||||
else()
|
||||
get_filename_component(sdl_vkimp_cpp_full_path ${CMAKE_CURRENT_SOURCE_DIR}/sys/sdl/sdl_vkimp.cpp ABSOLUTE)
|
||||
list(REMOVE_ITEM SDL_SOURCES "${sdl_vkimp_cpp_full_path}")
|
||||
endif()
|
||||
if(NOT USE_NVRHI)
|
||||
get_filename_component(devicemanager_h_full_path ${CMAKE_CURRENT_SOURCE_DIR}/sys/DeviceManager.h ABSOLUTE)
|
||||
list(REMOVE_ITEM SYS_INCLUDES "${devicemanager_h_full_path}")
|
||||
get_filename_component(devicemanager_cpp_full_path ${CMAKE_CURRENT_SOURCE_DIR}/sys/DeviceManager.cpp ABSOLUTE)
|
||||
list(REMOVE_ITEM SYS_SOURCES "${devicemanager_cpp_full_path}")
|
||||
get_filename_component(devicemanager_vk_cpp_full_path ${CMAKE_CURRENT_SOURCE_DIR}/sys/sdl/DeviceManager_VK.cpp ABSOLUTE)
|
||||
list(REMOVE_ITEM SDL_SOURCES "${devicemanager_vk_cpp_full_path}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
source_group("aas" FILES ${AAS_INCLUDES})
|
||||
|
@ -1892,9 +1885,8 @@ else()
|
|||
list(APPEND RBDOOM3_INCLUDES ${RENDERER_NVRHI_INCLUDES})
|
||||
list(APPEND RBDOOM3_SOURCES ${RENDERER_NVRHI_SOURCES})
|
||||
|
||||
set(OpenGL_LIBRARIES
|
||||
opengl32
|
||||
glu32)
|
||||
set(Vulkan_LIBRARIES
|
||||
${Vulkan_LIBRARY})
|
||||
else()
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIRS})
|
||||
|
@ -1909,7 +1901,7 @@ else()
|
|||
|
||||
if(USE_PRECOMPILED_HEADERS)
|
||||
set(RBDOOM3_PRECOMPILED_SOURCES ${RBDOOM3_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES} ${BINKDEC_SOURCES} ${IMGUI_SOURCES} ${MIKKTSPACE_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${TIMIDITY_SOURCES} ${JPEG_SOURCES} ${PNG_SOURCES} ${ZLIB_SOURCES} ${GLEW_SOURCES} ${BINKDEC_SOURCES} ${IMGUI_SOURCES} ${MIKKTSPACE_SOURCES} ${OGGVORBIS_SOURCES})
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libs/zlib/minizip/ioapi.c)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTDecoder.cpp)
|
||||
list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder.cpp)
|
||||
|
@ -2023,7 +2015,9 @@ if(USE_NVRHI_VULKAN)
|
|||
target_link_libraries(RBDoom3BFG nvrhi_vk)
|
||||
endif()
|
||||
|
||||
target_link_libraries(RBDoom3BFG nvrhi)
|
||||
if(USE_NVRHI)
|
||||
target_link_libraries(RBDoom3BFG nvrhi)
|
||||
|
||||
add_subdirectory(shaders)
|
||||
add_dependencies(RBDoom3BFG Shaders)
|
||||
add_subdirectory(shaders)
|
||||
add_dependencies(RBDoom3BFG Shaders)
|
||||
endif()
|
||||
|
|
|
@ -106,7 +106,12 @@ function(compile_shaders)
|
|||
endif()
|
||||
|
||||
if (NOT params_CFLAGS)
|
||||
set(CFLAGS "$<IF:$<CONFIG:Debug>,-Zi,> -fspv-target-env=vulkan1.2 -O3 -WX -Zpr")
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
# SRS - MoltenVK currently supports vulkan 1.1 (1.2 coming in next SDK release)
|
||||
set(CFLAGS "$<IF:$<CONFIG:Debug>,-Zi,> -fspv-target-env=vulkan1.1 -O3 -WX -Zpr")
|
||||
else()
|
||||
set(CFLAGS "$<IF:$<CONFIG:Debug>,-Zi,> -fspv-target-env=vulkan1.2 -O3 -WX -Zpr")
|
||||
endif()
|
||||
else()
|
||||
set(CFLAGS ${params_CFLAGS})
|
||||
endif()
|
||||
|
@ -114,7 +119,8 @@ function(compile_shaders)
|
|||
add_custom_command(TARGET ${params_TARGET} PRE_BUILD
|
||||
COMMAND shaderCompiler
|
||||
--infile ${params_CONFIG}
|
||||
--parallel
|
||||
# SRS - Parallel shader compilation sometimes fails, disable for now until issue is resolved
|
||||
# --parallel
|
||||
--out ${params_SPIRV_DXC}
|
||||
--platform spirv
|
||||
-I ${SHADER_INCLUDE_DIR}
|
||||
|
|
|
@ -466,7 +466,7 @@ RESULTS
|
|||
===================================================================== */
|
||||
void RevBytesSwap( void* bp, int elsize, int elcount )
|
||||
{
|
||||
register unsigned char* p, *q;
|
||||
unsigned char* p, *q;
|
||||
|
||||
p = ( unsigned char* ) bp;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ const int MAX_EXPRESSION_REGISTERS = 4096;
|
|||
// everything that is needed by the backend needs
|
||||
// to be double buffered to allow it to run in
|
||||
// parallel on a dual cpu machine
|
||||
#if defined(__APPLE__) && defined(USE_VULKAN)
|
||||
#if defined(__APPLE__) && ( defined( USE_VULKAN ) || defined( USE_NVRHI ) )
|
||||
// SRS - macOS MoltenVK/Metal needs triple buffering for full screen to work properly
|
||||
const uint32 NUM_FRAME_DATA = 3;
|
||||
#else
|
||||
|
|
|
@ -190,7 +190,9 @@ Defines and macros usable in all code
|
|||
|
||||
|
||||
// RB: changed UINT_PTR to uintptr_t
|
||||
#if !defined(__APPLE__)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#define _alloca16( x ) ((void *)ALIGN( (uintptr_t)_alloca( ALIGN( x, 16 ) + 16 ), 16 ) )
|
||||
#define _alloca128( x ) ((void *)ALIGN( (uintptr_t)_alloca( ALIGN( x, 128 ) + 128 ), 128 ) )
|
||||
// RB end
|
||||
|
|
|
@ -134,11 +134,11 @@ rgb_ycc_convert( j_compress_ptr cinfo,
|
|||
JDIMENSION output_row, int num_rows )
|
||||
{
|
||||
my_cconvert_ptr cconvert = ( my_cconvert_ptr ) cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register INT32* ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2;
|
||||
register JDIMENSION col;
|
||||
int r, g, b;
|
||||
INT32* ctab = cconvert->rgb_ycc_tab;
|
||||
JSAMPROW inptr;
|
||||
JSAMPROW outptr0, outptr1, outptr2;
|
||||
JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
|
||||
while( --num_rows >= 0 )
|
||||
|
@ -192,11 +192,11 @@ rgb_gray_convert( j_compress_ptr cinfo,
|
|||
JDIMENSION output_row, int num_rows )
|
||||
{
|
||||
my_cconvert_ptr cconvert = ( my_cconvert_ptr ) cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register INT32* ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
int r, g, b;
|
||||
INT32* ctab = cconvert->rgb_ycc_tab;
|
||||
JSAMPROW inptr;
|
||||
JSAMPROW outptr;
|
||||
JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
|
||||
while( --num_rows >= 0 )
|
||||
|
@ -233,11 +233,11 @@ cmyk_ycck_convert( j_compress_ptr cinfo,
|
|||
JDIMENSION output_row, int num_rows )
|
||||
{
|
||||
my_cconvert_ptr cconvert = ( my_cconvert_ptr ) cinfo->cconvert;
|
||||
register int r, g, b;
|
||||
register INT32* ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2, outptr3;
|
||||
register JDIMENSION col;
|
||||
int r, g, b;
|
||||
INT32* ctab = cconvert->rgb_ycc_tab;
|
||||
JSAMPROW inptr;
|
||||
JSAMPROW outptr0, outptr1, outptr2, outptr3;
|
||||
JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
|
||||
while( --num_rows >= 0 )
|
||||
|
@ -289,9 +289,9 @@ grayscale_convert( j_compress_ptr cinfo,
|
|||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows )
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
JSAMPROW inptr;
|
||||
JSAMPROW outptr;
|
||||
JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
int instride = cinfo->input_components;
|
||||
|
||||
|
@ -320,10 +320,10 @@ null_convert( j_compress_ptr cinfo,
|
|||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows )
|
||||
{
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
register int ci;
|
||||
JSAMPROW inptr;
|
||||
JSAMPROW outptr;
|
||||
JDIMENSION col;
|
||||
int ci;
|
||||
int nc = cinfo->num_components;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
|
||||
|
|
|
@ -211,9 +211,9 @@ forward_DCT( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
{
|
||||
/* Load data into workspace, applying unsigned->signed conversion */
|
||||
{
|
||||
register DCTELEM* workspaceptr;
|
||||
register JSAMPROW elemptr;
|
||||
register int elemr;
|
||||
DCTELEM* workspaceptr;
|
||||
JSAMPROW elemptr;
|
||||
int elemr;
|
||||
|
||||
workspaceptr = workspace;
|
||||
for( elemr = 0; elemr < DCTSIZE; elemr++ )
|
||||
|
@ -230,7 +230,7 @@ forward_DCT( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
*workspaceptr++ = GETJSAMPLE( *elemptr++ ) - CENTERJSAMPLE;
|
||||
#else
|
||||
{
|
||||
register int elemc;
|
||||
int elemc;
|
||||
for( elemc = DCTSIZE; elemc > 0; elemc-- )
|
||||
{
|
||||
*workspaceptr++ = GETJSAMPLE( *elemptr++ ) - CENTERJSAMPLE;
|
||||
|
@ -245,9 +245,9 @@ forward_DCT( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
|
||||
/* Quantize/descale the coefficients, and store into coef_blocks[] */
|
||||
{
|
||||
register DCTELEM temp, qval;
|
||||
register int i;
|
||||
register JCOEFPTR output_ptr = coef_blocks[bi];
|
||||
DCTELEM temp, qval;
|
||||
int i;
|
||||
JCOEFPTR output_ptr = coef_blocks[bi];
|
||||
|
||||
for( i = 0; i < DCTSIZE2; i++ )
|
||||
{
|
||||
|
@ -311,9 +311,9 @@ forward_DCT_float( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
{
|
||||
/* Load data into workspace, applying unsigned->signed conversion */
|
||||
{
|
||||
register FAST_FLOAT* workspaceptr;
|
||||
register JSAMPROW elemptr;
|
||||
register int elemr;
|
||||
FAST_FLOAT* workspaceptr;
|
||||
JSAMPROW elemptr;
|
||||
int elemr;
|
||||
|
||||
workspaceptr = workspace;
|
||||
for( elemr = 0; elemr < DCTSIZE; elemr++ )
|
||||
|
@ -330,7 +330,7 @@ forward_DCT_float( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
*workspaceptr++ = ( FAST_FLOAT )( GETJSAMPLE( *elemptr++ ) - CENTERJSAMPLE );
|
||||
#else
|
||||
{
|
||||
register int elemc;
|
||||
int elemc;
|
||||
for( elemc = DCTSIZE; elemc > 0; elemc-- )
|
||||
{
|
||||
*workspaceptr++ = ( FAST_FLOAT )
|
||||
|
@ -346,9 +346,9 @@ forward_DCT_float( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
|
||||
/* Quantize/descale the coefficients, and store into coef_blocks[] */
|
||||
{
|
||||
register FAST_FLOAT temp;
|
||||
register int i;
|
||||
register JCOEFPTR output_ptr = coef_blocks[bi];
|
||||
FAST_FLOAT temp;
|
||||
int i;
|
||||
JCOEFPTR output_ptr = coef_blocks[bi];
|
||||
|
||||
for( i = 0; i < DCTSIZE2; i++ )
|
||||
{
|
||||
|
|
|
@ -300,8 +300,8 @@ emit_bits( working_state* state, unsigned int code, int size )
|
|||
{
|
||||
/* Emit some bits; return TRUE if successful, FALSE if must suspend */
|
||||
/* This routine is heavily used, so it's worth coding tightly. */
|
||||
register INT32 put_buffer = ( INT32 ) code;
|
||||
register int put_bits = state->cur.put_bits;
|
||||
INT32 put_buffer = ( INT32 ) code;
|
||||
int put_bits = state->cur.put_bits;
|
||||
|
||||
/* if size is 0, caller used an invalid Huffman table entry */
|
||||
if( size == 0 )
|
||||
|
@ -356,9 +356,9 @@ LOCAL boolean
|
|||
encode_one_block( working_state* state, JCOEFPTR block, int last_dc_val,
|
||||
c_derived_tbl* dctbl, c_derived_tbl* actbl )
|
||||
{
|
||||
register int temp, temp2;
|
||||
register int nbits;
|
||||
register int k, r, i;
|
||||
int temp, temp2;
|
||||
int nbits;
|
||||
int k, r, i;
|
||||
|
||||
/* Encode the DC coefficient difference per section F.1.2.1 */
|
||||
|
||||
|
@ -616,9 +616,9 @@ LOCAL void
|
|||
htest_one_block( JCOEFPTR block, int last_dc_val,
|
||||
long dc_counts[], long ac_counts[] )
|
||||
{
|
||||
register int temp;
|
||||
register int nbits;
|
||||
register int k, r;
|
||||
int temp;
|
||||
int nbits;
|
||||
int k, r;
|
||||
|
||||
/* Encode the DC coefficient difference per section F.1.2.1 */
|
||||
|
||||
|
|
|
@ -274,8 +274,8 @@ emit_bits( phuff_entropy_ptr entropy, unsigned int code, int size )
|
|||
{
|
||||
/* Emit some bits, unless we are in gather mode */
|
||||
/* This routine is heavily used, so it's worth coding tightly. */
|
||||
register INT32 put_buffer = ( INT32 ) code;
|
||||
register int put_bits = entropy->put_bits;
|
||||
INT32 put_buffer = ( INT32 ) code;
|
||||
int put_bits = entropy->put_bits;
|
||||
|
||||
/* if size is 0, caller used an invalid Huffman table entry */
|
||||
if( size == 0 )
|
||||
|
@ -372,7 +372,7 @@ emit_buffered_bits( phuff_entropy_ptr entropy, char* bufstart,
|
|||
LOCAL void
|
||||
emit_eobrun( phuff_entropy_ptr entropy )
|
||||
{
|
||||
register int temp, nbits;
|
||||
int temp, nbits;
|
||||
|
||||
if( entropy->EOBRUN > 0 ) /* if there is any pending EOBRUN */
|
||||
{
|
||||
|
@ -442,8 +442,8 @@ METHODDEF boolean
|
|||
encode_mcu_DC_first( j_compress_ptr cinfo, JBLOCKROW* MCU_data )
|
||||
{
|
||||
phuff_entropy_ptr entropy = ( phuff_entropy_ptr ) cinfo->entropy;
|
||||
register int temp, temp2;
|
||||
register int nbits;
|
||||
int temp, temp2;
|
||||
int nbits;
|
||||
int blkn, ci;
|
||||
int Al = cinfo->Al;
|
||||
JBLOCKROW block;
|
||||
|
@ -535,9 +535,9 @@ METHODDEF boolean
|
|||
encode_mcu_AC_first( j_compress_ptr cinfo, JBLOCKROW* MCU_data )
|
||||
{
|
||||
phuff_entropy_ptr entropy = ( phuff_entropy_ptr ) cinfo->entropy;
|
||||
register int temp, temp2;
|
||||
register int nbits;
|
||||
register int r, k;
|
||||
int temp, temp2;
|
||||
int nbits;
|
||||
int r, k;
|
||||
int Se = cinfo->Se;
|
||||
int Al = cinfo->Al;
|
||||
JBLOCKROW block;
|
||||
|
@ -659,7 +659,7 @@ METHODDEF boolean
|
|||
encode_mcu_DC_refine( j_compress_ptr cinfo, JBLOCKROW* MCU_data )
|
||||
{
|
||||
phuff_entropy_ptr entropy = ( phuff_entropy_ptr ) cinfo->entropy;
|
||||
register int temp;
|
||||
int temp;
|
||||
int blkn;
|
||||
int Al = cinfo->Al;
|
||||
JBLOCKROW block;
|
||||
|
@ -713,8 +713,8 @@ METHODDEF boolean
|
|||
encode_mcu_AC_refine( j_compress_ptr cinfo, JBLOCKROW* MCU_data )
|
||||
{
|
||||
phuff_entropy_ptr entropy = ( phuff_entropy_ptr ) cinfo->entropy;
|
||||
register int temp;
|
||||
register int r, k;
|
||||
int temp;
|
||||
int r, k;
|
||||
int EOB;
|
||||
char* BR_buffer;
|
||||
unsigned int BR;
|
||||
|
|
|
@ -109,7 +109,7 @@ LOCAL void
|
|||
expand_bottom_edge( JSAMPARRAY image_data, JDIMENSION num_cols,
|
||||
int input_rows, int output_rows )
|
||||
{
|
||||
register int row;
|
||||
int row;
|
||||
|
||||
for( row = input_rows; row < output_rows; row++ )
|
||||
{
|
||||
|
|
|
@ -88,9 +88,9 @@ LOCAL void
|
|||
expand_right_edge( JSAMPARRAY image_data, int num_rows,
|
||||
JDIMENSION input_cols, JDIMENSION output_cols )
|
||||
{
|
||||
register JSAMPROW ptr;
|
||||
register JSAMPLE pixval;
|
||||
register int count;
|
||||
JSAMPROW ptr;
|
||||
JSAMPLE pixval;
|
||||
int count;
|
||||
int row;
|
||||
int numcols = ( int )( output_cols - input_cols );
|
||||
|
||||
|
@ -225,8 +225,8 @@ h2v1_downsample( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
int outrow;
|
||||
JDIMENSION outcol;
|
||||
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register int bias;
|
||||
JSAMPROW inptr, outptr;
|
||||
int bias;
|
||||
|
||||
/* Expand input data enough to let all the output samples be generated
|
||||
* by the standard loop. Special-casing padded output would be more
|
||||
|
@ -264,8 +264,8 @@ h2v2_downsample( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
int inrow, outrow;
|
||||
JDIMENSION outcol;
|
||||
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
|
||||
register JSAMPROW inptr0, inptr1, outptr;
|
||||
register int bias;
|
||||
JSAMPROW inptr0, inptr1, outptr;
|
||||
int bias;
|
||||
|
||||
/* Expand input data enough to let all the output samples be generated
|
||||
* by the standard loop. Special-casing padded output would be more
|
||||
|
@ -310,7 +310,7 @@ h2v2_smooth_downsample( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
int inrow, outrow;
|
||||
JDIMENSION colctr;
|
||||
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
|
||||
register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;
|
||||
JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;
|
||||
INT32 membersum, neighsum, memberscale, neighscale;
|
||||
|
||||
/* Expand input data enough to let all the output samples be generated
|
||||
|
@ -418,7 +418,7 @@ fullsize_smooth_downsample( j_compress_ptr cinfo, jpeg_component_info* compptr,
|
|||
int outrow;
|
||||
JDIMENSION colctr;
|
||||
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
|
||||
register JSAMPROW inptr, above_ptr, below_ptr, outptr;
|
||||
JSAMPROW inptr, above_ptr, below_ptr, outptr;
|
||||
INT32 membersum, neighsum, memberscale, neighscale;
|
||||
int colsum, lastcolsum, nextcolsum;
|
||||
|
||||
|
|
|
@ -124,17 +124,17 @@ ycc_rgb_convert( j_decompress_ptr cinfo,
|
|||
JSAMPARRAY output_buf, int num_rows )
|
||||
{
|
||||
my_cconvert_ptr cconvert = ( my_cconvert_ptr ) cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
int y, cb, cr;
|
||||
JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE* range_limit = cinfo->sample_range_limit;
|
||||
register int* Crrtab = cconvert->Cr_r_tab;
|
||||
register int* Cbbtab = cconvert->Cb_b_tab;
|
||||
register INT32* Crgtab = cconvert->Cr_g_tab;
|
||||
register INT32* Cbgtab = cconvert->Cb_g_tab;
|
||||
JSAMPLE* range_limit = cinfo->sample_range_limit;
|
||||
int* Crrtab = cconvert->Cr_r_tab;
|
||||
int* Cbbtab = cconvert->Cb_b_tab;
|
||||
INT32* Crgtab = cconvert->Cr_g_tab;
|
||||
INT32* Cbgtab = cconvert->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
while( --num_rows >= 0 )
|
||||
|
@ -174,9 +174,9 @@ null_convert( j_decompress_ptr cinfo,
|
|||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows )
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION count;
|
||||
register int num_components = cinfo->num_components;
|
||||
JSAMPROW inptr, outptr;
|
||||
JDIMENSION count;
|
||||
int num_components = cinfo->num_components;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
int ci;
|
||||
|
||||
|
@ -227,17 +227,17 @@ ycck_cmyk_convert( j_decompress_ptr cinfo,
|
|||
JSAMPARRAY output_buf, int num_rows )
|
||||
{
|
||||
my_cconvert_ptr cconvert = ( my_cconvert_ptr ) cinfo->cconvert;
|
||||
register int y, cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2, inptr3;
|
||||
register JDIMENSION col;
|
||||
int y, cb, cr;
|
||||
JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2, inptr3;
|
||||
JDIMENSION col;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE* range_limit = cinfo->sample_range_limit;
|
||||
register int* Crrtab = cconvert->Cr_r_tab;
|
||||
register int* Cbbtab = cconvert->Cb_b_tab;
|
||||
register INT32* Crgtab = cconvert->Cr_g_tab;
|
||||
register INT32* Cbgtab = cconvert->Cb_g_tab;
|
||||
JSAMPLE* range_limit = cinfo->sample_range_limit;
|
||||
int* Crrtab = cconvert->Cr_r_tab;
|
||||
int* Cbbtab = cconvert->Cb_b_tab;
|
||||
INT32* Crgtab = cconvert->Cr_g_tab;
|
||||
INT32* Cbgtab = cconvert->Cb_g_tab;
|
||||
SHIFT_TEMPS
|
||||
|
||||
while( --num_rows >= 0 )
|
||||
|
|
|
@ -255,14 +255,14 @@ jpeg_make_d_derived_tbl( j_decompress_ptr cinfo, JHUFF_TBL* htbl,
|
|||
|
||||
GLOBAL boolean
|
||||
jpeg_fill_bit_buffer( bitread_working_state* state,
|
||||
register bit_buf_type get_buffer, register int bits_left,
|
||||
bit_buf_type get_buffer, int bits_left,
|
||||
int nbits )
|
||||
{
|
||||
/* Load up the bit buffer to a depth of at least nbits */
|
||||
/* Copy heavily used state fields into locals (hopefully registers) */
|
||||
register const JOCTET* next_input_byte = state->next_input_byte;
|
||||
register size_t bytes_in_buffer = state->bytes_in_buffer;
|
||||
register int c;
|
||||
const JOCTET* next_input_byte = state->next_input_byte;
|
||||
size_t bytes_in_buffer = state->bytes_in_buffer;
|
||||
int c;
|
||||
|
||||
/* Attempt to load at least MIN_GET_BITS bits into get_buffer. */
|
||||
/* (It is assumed that no request will be for more than that many bits.) */
|
||||
|
@ -361,11 +361,11 @@ no_more_data:
|
|||
|
||||
GLOBAL int
|
||||
jpeg_huff_decode( bitread_working_state* state,
|
||||
register bit_buf_type get_buffer, register int bits_left,
|
||||
bit_buf_type get_buffer, int bits_left,
|
||||
d_derived_tbl* htbl, int min_bits )
|
||||
{
|
||||
register int l = min_bits;
|
||||
register INT32 code;
|
||||
int l = min_bits;
|
||||
INT32 code;
|
||||
|
||||
/* HUFF_DECODE has determined that the code is at least min_bits */
|
||||
/* bits long, so fetch that many bits in one swoop. */
|
||||
|
@ -490,7 +490,7 @@ METHODDEF boolean
|
|||
decode_mcu( j_decompress_ptr cinfo, JBLOCKROW* MCU_data )
|
||||
{
|
||||
huff_entropy_ptr entropy = ( huff_entropy_ptr ) cinfo->entropy;
|
||||
register int s, k, r;
|
||||
int s, k, r;
|
||||
int blkn, ci;
|
||||
JBLOCKROW block;
|
||||
BITREAD_STATE_VARS;
|
||||
|
|
|
@ -101,8 +101,8 @@ typedef struct /* Bitreading working state within an MCU */
|
|||
|
||||
/* Macros to declare and load/save bitread local variables. */
|
||||
#define BITREAD_STATE_VARS \
|
||||
register bit_buf_type get_buffer; \
|
||||
register int bits_left; \
|
||||
bit_buf_type get_buffer; \
|
||||
int bits_left; \
|
||||
bitread_working_state br_state
|
||||
|
||||
#define BITREAD_LOAD_STATE(cinfop,permstate) \
|
||||
|
@ -156,7 +156,7 @@ typedef struct /* Bitreading working state within an MCU */
|
|||
|
||||
/* Load up the bit buffer to a depth of at least nbits */
|
||||
EXTERN boolean jpeg_fill_bit_buffer JPP( ( bitread_working_state* state,
|
||||
register bit_buf_type get_buffer, register int bits_left,
|
||||
bit_buf_type get_buffer, int bits_left,
|
||||
int nbits ) );
|
||||
|
||||
|
||||
|
@ -178,7 +178,7 @@ EXTERN boolean jpeg_fill_bit_buffer JPP( ( bitread_working_state* state,
|
|||
*/
|
||||
|
||||
#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \
|
||||
{ register int nb, look; \
|
||||
{ int nb, look; \
|
||||
if (bits_left < HUFF_LOOKAHEAD) { \
|
||||
if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \
|
||||
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
||||
|
@ -201,5 +201,5 @@ slowlabel: \
|
|||
|
||||
/* Out-of-line case for Huffman code fetching */
|
||||
EXTERN int jpeg_huff_decode JPP( ( bitread_working_state* state,
|
||||
register bit_buf_type get_buffer, register int bits_left,
|
||||
bit_buf_type get_buffer, int bits_left,
|
||||
d_derived_tbl* htbl, int min_bits ) );
|
||||
|
|
|
@ -200,9 +200,9 @@ int_upsample( j_decompress_ptr cinfo, jpeg_component_info* compptr,
|
|||
{
|
||||
my_upsample_ptr upsample = ( my_upsample_ptr ) cinfo->upsample;
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JSAMPLE invalue;
|
||||
register int h;
|
||||
JSAMPROW inptr, outptr;
|
||||
JSAMPLE invalue;
|
||||
int h;
|
||||
JSAMPROW outend;
|
||||
int h_expand, v_expand;
|
||||
int inrow, outrow;
|
||||
|
@ -247,8 +247,8 @@ h2v1_upsample( j_decompress_ptr cinfo, jpeg_component_info* compptr,
|
|||
JSAMPARRAY input_data, JSAMPARRAY* output_data_ptr )
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JSAMPLE invalue;
|
||||
JSAMPROW inptr, outptr;
|
||||
JSAMPLE invalue;
|
||||
JSAMPROW outend;
|
||||
int inrow;
|
||||
|
||||
|
@ -277,8 +277,8 @@ h2v2_upsample( j_decompress_ptr cinfo, jpeg_component_info* compptr,
|
|||
JSAMPARRAY input_data, JSAMPARRAY* output_data_ptr )
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JSAMPLE invalue;
|
||||
JSAMPROW inptr, outptr;
|
||||
JSAMPLE invalue;
|
||||
JSAMPROW outend;
|
||||
int inrow, outrow;
|
||||
|
||||
|
@ -322,9 +322,9 @@ h2v1_fancy_upsample( j_decompress_ptr cinfo, jpeg_component_info* compptr,
|
|||
JSAMPARRAY input_data, JSAMPARRAY* output_data_ptr )
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
register JSAMPROW inptr, outptr;
|
||||
register int invalue;
|
||||
register JDIMENSION colctr;
|
||||
JSAMPROW inptr, outptr;
|
||||
int invalue;
|
||||
JDIMENSION colctr;
|
||||
int inrow;
|
||||
|
||||
for( inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++ )
|
||||
|
@ -365,13 +365,13 @@ h2v2_fancy_upsample( j_decompress_ptr cinfo, jpeg_component_info* compptr,
|
|||
JSAMPARRAY input_data, JSAMPARRAY* output_data_ptr )
|
||||
{
|
||||
JSAMPARRAY output_data = *output_data_ptr;
|
||||
register JSAMPROW inptr0, inptr1, outptr;
|
||||
JSAMPROW inptr0, inptr1, outptr;
|
||||
#if BITS_IN_JSAMPLE == 8
|
||||
register int thiscolsum, lastcolsum, nextcolsum;
|
||||
int thiscolsum, lastcolsum, nextcolsum;
|
||||
#else
|
||||
register INT32 thiscolsum, lastcolsum, nextcolsum;
|
||||
INT32 thiscolsum, lastcolsum, nextcolsum;
|
||||
#endif
|
||||
register JDIMENSION colctr;
|
||||
JDIMENSION colctr;
|
||||
int inrow, outrow, v;
|
||||
|
||||
inrow = outrow = 0;
|
||||
|
|
|
@ -115,13 +115,13 @@ jcopy_sample_rows( JSAMPARRAY input_array, int source_row,
|
|||
* to output_array[dest_row++]; these areas may overlap for duplication.
|
||||
* The source and destination arrays must be at least as wide as num_cols.
|
||||
*/
|
||||
register JSAMPROW inptr, outptr;
|
||||
JSAMPROW inptr, outptr;
|
||||
#ifdef FMEMCOPY
|
||||
register size_t count = ( size_t )( num_cols * SIZEOF( JSAMPLE ) );
|
||||
size_t count = ( size_t )( num_cols * SIZEOF( JSAMPLE ) );
|
||||
#else
|
||||
register JDIMENSION count;
|
||||
JDIMENSION count;
|
||||
#endif
|
||||
register int row;
|
||||
int row;
|
||||
|
||||
input_array += source_row;
|
||||
output_array += dest_row;
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
#if defined( USE_VULKAN )
|
||||
VkBuffer GetAPIObject() const
|
||||
{
|
||||
return apiObject;
|
||||
return bufferHandle;
|
||||
}
|
||||
#elif defined( USE_NVRHI )
|
||||
nvrhi::IBuffer* GetAPIObject() const
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
#else
|
||||
GLintptr GetAPIObject() const
|
||||
{
|
||||
return apiObject;
|
||||
return bufferHandle;
|
||||
}
|
||||
#endif
|
||||
int GetOffset() const
|
||||
|
|
|
@ -402,7 +402,7 @@ void idGuiModel::EmitImGui( ImDrawData* drawData )
|
|||
mat = ( const idMaterial* )pcmd->TextureId;
|
||||
}
|
||||
|
||||
idScreenRect clipRect = { pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w };
|
||||
idScreenRect clipRect = { static_cast<short>(pcmd->ClipRect.x), static_cast<short>(pcmd->ClipRect.y), static_cast<short>(pcmd->ClipRect.z), static_cast<short>(pcmd->ClipRect.w) };
|
||||
|
||||
idDrawVert* verts = AllocTris( numVerts, indexBufferOffset, numIndexes, mat, tr.currentGLState, STEREO_DEPTH_TYPE_NONE, clipRect );
|
||||
if( verts == NULL )
|
||||
|
|
|
@ -150,7 +150,7 @@ void fhImmediateMode::End()
|
|||
uint64_t stateBits = tr.backend.glStateBits;
|
||||
|
||||
int program = renderProgManager.CurrentProgram();
|
||||
PipelineKey key{ stateBits, program, tr.backend.depthBias, tr.backend.slopeScaleBias, tr.backend.currentFrameBuffer };
|
||||
PipelineKey key{ stateBits, program, static_cast<int>(tr.backend.depthBias), tr.backend.slopeScaleBias, tr.backend.currentFrameBuffer };
|
||||
auto pipeline = tr.backend.pipelineCache.GetOrCreatePipeline( key );
|
||||
|
||||
{
|
||||
|
@ -514,4 +514,4 @@ void fhLineBuffer::Clear()
|
|||
{
|
||||
verticesUsed = 0;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -238,13 +238,13 @@ public:
|
|||
const idJointQuat* GetDefaultPose() const override;
|
||||
int NearestJoint( int surfaceNum, int a, int b, int c ) const override;
|
||||
|
||||
virtual bool SupportsBinaryModel()
|
||||
bool SupportsBinaryModel() override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// RB begin
|
||||
virtual void ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp = NULL );
|
||||
void ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp = NULL ) override;
|
||||
// RB end
|
||||
|
||||
private:
|
||||
|
|
|
@ -55,7 +55,8 @@ idCVar stereoRender_warpTargetFraction( "stereoRender_warpTargetFraction", "1.0"
|
|||
idCVar r_showSwapBuffers( "r_showSwapBuffers", "0", CVAR_BOOL, "Show timings from GL_BlockingSwapBuffers" );
|
||||
idCVar r_syncEveryFrame( "r_syncEveryFrame", "1", CVAR_BOOL, "Don't let the GPU buffer execution past swapbuffers" );
|
||||
|
||||
void GLimp_SwapBuffers();
|
||||
// SRS - What is GLimp_SwapBuffers() used for? Disable for now
|
||||
//void GLimp_SwapBuffers();
|
||||
void RB_SetMVP( const idRenderMatrix& mvp );
|
||||
|
||||
class NvrhiContext
|
||||
|
@ -110,7 +111,11 @@ void idRenderBackend::Init()
|
|||
}
|
||||
|
||||
// DG: make sure SDL has setup video so getting supported modes in R_SetNewMode() works
|
||||
#if defined( VULKAN_USE_PLATFORM_SDL )
|
||||
VKimp_PreInit();
|
||||
#else
|
||||
GLimp_PreInit();
|
||||
#endif
|
||||
// DG end
|
||||
|
||||
R_SetNewMode( true );
|
||||
|
@ -191,7 +196,12 @@ void idRenderBackend::Init()
|
|||
void idRenderBackend::Shutdown()
|
||||
{
|
||||
delete ssaoPass;
|
||||
|
||||
#if defined( VULKAN_USE_PLATFORM_SDL )
|
||||
VKimp_Shutdown();
|
||||
#else
|
||||
GLimp_Shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -337,7 +347,7 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
const uint64_t stateBits = glStateBits;
|
||||
|
||||
const int program = renderProgManager.CurrentProgram();
|
||||
const PipelineKey key{ stateBits, program, depthBias, slopeScaleBias, currentFrameBuffer };
|
||||
const PipelineKey key{ stateBits, program, static_cast<int>(depthBias), slopeScaleBias, currentFrameBuffer };
|
||||
const auto pipeline = pipelineCache.GetOrCreatePipeline( key );
|
||||
|
||||
if( currentPipeline != pipeline )
|
||||
|
@ -1690,27 +1700,6 @@ void idRenderBackend::CheckCVars()
|
|||
}
|
||||
}*/
|
||||
|
||||
// SRS - Enable SDL-driven vync changes without restart for UNIX-like OSs
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
|
||||
extern idCVar r_swapInterval;
|
||||
if( r_swapInterval.IsModified() )
|
||||
{
|
||||
r_swapInterval.ClearModified();
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
if( SDL_GL_SetSwapInterval( r_swapInterval.GetInteger() ) < 0 )
|
||||
{
|
||||
common->Warning( "Vsync changes not supported without restart" );
|
||||
}
|
||||
#else
|
||||
if( SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, r_swapInterval.GetInteger() ) < 0 )
|
||||
{
|
||||
common->Warning( "Vsync changes not supported without restart" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
// SRS end
|
||||
|
||||
#if 0
|
||||
if( r_antiAliasing.IsModified() )
|
||||
{
|
||||
|
|
|
@ -281,7 +281,8 @@ void TemporalAntiAliasingPass::TemporalResolve(
|
|||
taaConstants.outputViewSize = idVec2( viewportOutput.width() + 1, viewportOutput.height() + 1 );
|
||||
//taaConstants.inputPixelOffset.Set( 0, 0 ); // TODO = viewInput->GetPixelOffset();
|
||||
taaConstants.inputPixelOffset = GetCurrentPixelOffset();
|
||||
taaConstants.outputTextureSizeInv = 1.0f / idVec2( float( renderSystem->GetWidth() ), float( renderSystem->GetHeight() ) );
|
||||
// SRS - FIXME: Is this correct? Replaces 1.0f / idVec2 () which does not compile using Clang
|
||||
taaConstants.outputTextureSizeInv = idVec2( 1.0f, 1.0f ) / idVec2( float( renderSystem->GetWidth() ), float( renderSystem->GetHeight() ) );
|
||||
taaConstants.inputOverOutputViewSize = taaConstants.inputViewSize / taaConstants.outputViewSize;
|
||||
taaConstants.outputOverInputViewSize = taaConstants.outputViewSize / taaConstants.inputViewSize;
|
||||
taaConstants.clampingFactor = params.enableHistoryClamping ? params.clampingFactor : -1.f;
|
||||
|
@ -339,7 +340,7 @@ idVec2 TemporalAntiAliasingPass::GetCurrentPixelOffset()
|
|||
switch( r_taaJitter.GetInteger() )
|
||||
{
|
||||
default:
|
||||
case TemporalAntiAliasingJitter::MSAA:
|
||||
case (int)TemporalAntiAliasingJitter::MSAA:
|
||||
{
|
||||
const idVec2 offsets[] =
|
||||
{
|
||||
|
@ -349,22 +350,22 @@ idVec2 TemporalAntiAliasingPass::GetCurrentPixelOffset()
|
|||
|
||||
return offsets[m_FrameIndex % 8];
|
||||
}
|
||||
case TemporalAntiAliasingJitter::Halton:
|
||||
case (int)TemporalAntiAliasingJitter::Halton:
|
||||
{
|
||||
uint32_t index = ( m_FrameIndex % 16 ) + 1;
|
||||
return idVec2{ VanDerCorput( 2, index ), VanDerCorput( 3, index ) } - idVec2( 0.5f, 0.5f );
|
||||
}
|
||||
case TemporalAntiAliasingJitter::R2:
|
||||
case (int)TemporalAntiAliasingJitter::R2:
|
||||
{
|
||||
return m_R2Jitter - idVec2( 0.5f, 0.5f );
|
||||
}
|
||||
case TemporalAntiAliasingJitter::WhiteNoise:
|
||||
case (int)TemporalAntiAliasingJitter::WhiteNoise:
|
||||
{
|
||||
std::mt19937 rng( m_FrameIndex );
|
||||
std::uniform_real_distribution<float> dist( -0.5f, 0.5f );
|
||||
return idVec2{ dist( rng ), dist( rng ) };
|
||||
}
|
||||
case TemporalAntiAliasingJitter::None:
|
||||
case (int)TemporalAntiAliasingJitter::None:
|
||||
{
|
||||
return idVec2( 0, 0 );
|
||||
}
|
||||
|
|
|
@ -7011,8 +7011,8 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
|
||||
#if !defined( USE_VULKAN )
|
||||
|
||||
// SRS - For OSX OpenGL record the final portion of GPU time while no other elapsed time query is active (after final shader pass and before post processing)
|
||||
#if defined(__APPLE__)
|
||||
// SRS - For OSX OpenGL record the final portion of GPU time while no other elapsed time query is active (after final passes and before bloom & other post processing)
|
||||
#if defined(__APPLE__) && !defined( USE_NVRHI )
|
||||
renderLog.OpenMainBlock( MRB_GPU_TIME );
|
||||
#endif
|
||||
|
||||
|
@ -7054,6 +7054,11 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
#endif
|
||||
}
|
||||
|
||||
// SRS - This macOS OpenGL-specific CloseMainBlock() must occur before the next OpenMainBlock() is called
|
||||
#if defined(__APPLE__) && !defined( USE_NVRHI )
|
||||
renderLog.CloseMainBlock();
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------
|
||||
// bloom post processing
|
||||
//-------------------------------------------------
|
||||
|
@ -7066,10 +7071,6 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
renderLog.CloseMainBlock();
|
||||
#endif
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
//TODO(Stephen): Move somewhere else?
|
||||
// RB: this needs to be done after next post processing steps later on
|
||||
|
|
|
@ -1419,10 +1419,13 @@ struct glimpParms_t
|
|||
#include <vector>
|
||||
|
||||
#define CLAMP(x, lo, hi) ((x) < (lo) ? (lo) : (x) > (hi) ? (hi) : (x))
|
||||
// Helper function for using SDL2 and Vulkan on Linux.
|
||||
// Helper functions for using SDL2 and Vulkan on Linux.
|
||||
std::vector<const char*> get_required_extensions();
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
bool CreateSDLWindowSurface( VkInstance instance, VkSurfaceKHR* surface );
|
||||
#else
|
||||
extern vulkanContext_t vkcontext;
|
||||
#endif
|
||||
|
||||
// DG: R_GetModeListForDisplay is called before GLimp_Init(), but SDL needs SDL_Init() first.
|
||||
// So add PreInit for platforms that need it, others can just stub it.
|
||||
|
|
|
@ -528,7 +528,7 @@ void R_SetNewMode( const bool fullInit )
|
|||
deviceManager = DeviceManager::Create( api );
|
||||
#endif
|
||||
|
||||
#if defined( USE_VULKAN )
|
||||
#if defined( VULKAN_USE_PLATFORM_SDL )
|
||||
if( VKimp_Init( parms ) )
|
||||
#else
|
||||
if( GLimp_Init( parms ) )
|
||||
|
@ -542,7 +542,7 @@ void R_SetNewMode( const bool fullInit )
|
|||
{
|
||||
// just rebuild the window
|
||||
|
||||
#if defined( USE_VULKAN )
|
||||
#if defined( VULKAN_USE_PLATFORM_SDL )
|
||||
if( VKimp_SetScreenParms( parms ) )
|
||||
#else
|
||||
if( GLimp_SetScreenParms( parms ) )
|
||||
|
|
|
@ -285,17 +285,17 @@ static void R_SortDrawSurfs( drawSurf_t** drawSurfs, const int numDrawSurfs )
|
|||
int64 hi[MAX_LEVELS];
|
||||
|
||||
// Keep the top of the stack in registers to avoid load-hit-stores.
|
||||
register int64 st_lo = 0;
|
||||
register int64 st_hi = numDrawSurfs - 1;
|
||||
register int64 level = 0;
|
||||
int64 st_lo = 0;
|
||||
int64 st_hi = numDrawSurfs - 1;
|
||||
int64 level = 0;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
register int64 i = st_lo;
|
||||
register int64 j = st_hi;
|
||||
int64 i = st_lo;
|
||||
int64 j = st_hi;
|
||||
if( j - i >= 4 && level < MAX_LEVELS - 1 )
|
||||
{
|
||||
register uint64 pivot = indices[( i + j ) / 2];
|
||||
uint64 pivot = indices[( i + j ) / 2];
|
||||
do
|
||||
{
|
||||
while( indices[i] > pivot )
|
||||
|
@ -330,7 +330,7 @@ static void R_SortDrawSurfs( drawSurf_t** drawSurfs, const int numDrawSurfs )
|
|||
{
|
||||
for( ; i < j; j-- )
|
||||
{
|
||||
register int64 m = i;
|
||||
int64 m = i;
|
||||
for( int64 k = i + 1; k <= j; k++ )
|
||||
{
|
||||
if( indices[k] < indices[m] )
|
||||
|
|
|
@ -23,7 +23,7 @@ DeviceManager* DeviceManager::Create( nvrhi::GraphicsAPI api )
|
|||
return CreateVK();
|
||||
#endif
|
||||
default:
|
||||
common->Error( "DeviceManager::Create: Unsupported Graphics API (%d)", api );
|
||||
common->Error( "DeviceManager::Create: Unsupported Graphics API (%u)", (unsigned int)api );
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -101,10 +101,10 @@ void DefaultMessageCallback::message( nvrhi::MessageSeverity severity, const cha
|
|||
common->Warning( messageText );
|
||||
break;
|
||||
case nvrhi::MessageSeverity::Error:
|
||||
common->FatalError( messageText );
|
||||
common->FatalError( "%s", messageText );
|
||||
break;
|
||||
case nvrhi::MessageSeverity::Fatal:
|
||||
common->FatalError( messageText );
|
||||
common->FatalError( "%s", messageText );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
1194
neo/sys/sdl/DeviceManager_VK.cpp
Normal file
1194
neo/sys/sdl/DeviceManager_VK.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -50,6 +50,11 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "renderer/RenderCommon.h"
|
||||
#include "sdl_local.h"
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
#include <sys/DeviceManager.h>
|
||||
extern DeviceManager* deviceManager;
|
||||
#endif
|
||||
|
||||
idCVar in_nograb( "in_nograb", "0", CVAR_SYSTEM | CVAR_NOCHEAT, "prevents input grabbing" );
|
||||
|
||||
// RB: FIXME this shit. We need the OpenGL alpha channel for advanced rendering effects
|
||||
|
@ -80,22 +85,9 @@ std::vector<const char*> get_required_extensions()
|
|||
uint32_t sdlCount = 0;
|
||||
std::vector<const char*> sdlInstanceExtensions = {};
|
||||
|
||||
SDL_Vulkan_GetInstanceExtensions( nullptr, &sdlCount, nullptr );
|
||||
SDL_Vulkan_GetInstanceExtensions( window, &sdlCount, nullptr );
|
||||
sdlInstanceExtensions.resize( sdlCount );
|
||||
SDL_Vulkan_GetInstanceExtensions( nullptr, &sdlCount, sdlInstanceExtensions.data() );
|
||||
|
||||
// SRS - Report enabled instance extensions in CreateVulkanInstance() vs. doing it here
|
||||
/*
|
||||
if( enableValidationLayers )
|
||||
{
|
||||
idLib::Printf( "\nNumber of availiable instance extensions\t%i\n", sdlCount );
|
||||
idLib::Printf( "Available Extension List: \n" );
|
||||
for( auto ext : sdlInstanceExtensions )
|
||||
{
|
||||
idLib::Printf( "\t%s\n", ext );
|
||||
}
|
||||
}
|
||||
*/
|
||||
SDL_Vulkan_GetInstanceExtensions( window, &sdlCount, sdlInstanceExtensions.data() );
|
||||
|
||||
// SRS - needed for MoltenVK portability implementation and optionally for MoltenVK configuration on OSX
|
||||
#if defined(__APPLE__)
|
||||
|
@ -104,26 +96,86 @@ std::vector<const char*> get_required_extensions()
|
|||
sdlInstanceExtensions.push_back( VK_MVK_MOLTENVK_EXTENSION_NAME );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// SRS - Add debug instance extensions in CreateVulkanInstance() vs. hardcoding them here
|
||||
/*
|
||||
if( enableValidationLayers )
|
||||
{
|
||||
sdlInstanceExtensions.push_back( "VK_EXT_debug_report" );
|
||||
sdlInstanceExtensions.push_back( "VK_EXT_debug_utils" );
|
||||
|
||||
idLib::Printf( "Number of active instance extensions\t%zu\n", sdlInstanceExtensions.size() );
|
||||
idLib::Printf( "Active Extension List: \n" );
|
||||
for( auto const& ext : sdlInstanceExtensions )
|
||||
{
|
||||
idLib::Printf( "\t%s\n", ext );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return sdlInstanceExtensions;
|
||||
}
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
bool CreateSDLWindowSurface( VkInstance instance, VkSurfaceKHR* surface )
|
||||
{
|
||||
if( !SDL_Vulkan_CreateSurface( window, instance, surface ) )
|
||||
{
|
||||
common->Warning( "Error while creating SDL Vulkan surface: %s", SDL_GetError() );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceManager::CreateWindowDeviceAndSwapChain( const glimpParms_t& parms, const char* windowTitle )
|
||||
{
|
||||
Uint32 flags = SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE;
|
||||
if( parms.fullScreen )
|
||||
{
|
||||
flags |= SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
|
||||
window = SDL_CreateWindow( GAME_NAME,
|
||||
parms.x,
|
||||
parms.y,
|
||||
parms.width, parms.height, flags );
|
||||
|
||||
if( !window )
|
||||
{
|
||||
common->Printf( "^3SDL_CreateWindow() - Couldn't create window^0\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// RB
|
||||
deviceParms.backBufferWidth = parms.width;
|
||||
deviceParms.backBufferHeight = parms.height;
|
||||
deviceParms.backBufferSampleCount = parms.multiSamples;
|
||||
deviceParms.vsyncEnabled = requestedVSync;
|
||||
|
||||
if( !CreateDeviceAndSwapChain() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
glConfig.isFullscreen = parms.fullScreen;
|
||||
|
||||
UpdateWindowSize( parms );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceManager::UpdateWindowSize( const glimpParms_t& params )
|
||||
{
|
||||
windowVisible = true;
|
||||
|
||||
if( int( deviceParms.backBufferWidth ) != params.width ||
|
||||
int( deviceParms.backBufferHeight ) != params.height ||
|
||||
#if ID_MSAA
|
||||
int( deviceParms.backBufferSampleCount ) != params.multiSamples ||
|
||||
#endif
|
||||
( deviceParms.vsyncEnabled != requestedVSync && GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) )
|
||||
{
|
||||
// window is not minimized, and the size has changed
|
||||
|
||||
BackBufferResizing();
|
||||
|
||||
deviceParms.backBufferWidth = params.width;
|
||||
deviceParms.backBufferHeight = params.height;
|
||||
deviceParms.backBufferSampleCount = params.multiSamples;
|
||||
deviceParms.vsyncEnabled = requestedVSync;
|
||||
|
||||
ResizeSwapChain();
|
||||
BackBufferResized();
|
||||
}
|
||||
|
||||
deviceParms.vsyncEnabled = requestedVSync;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
===================
|
||||
VKimp_PreInit
|
||||
|
@ -279,31 +331,41 @@ bool VKimp_Init( glimpParms_t parms )
|
|||
* the mouse cursor.
|
||||
*/
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
glimpParms_t createParms = parms;
|
||||
createParms.x = createParms.y = windowPos;
|
||||
|
||||
if( !deviceManager->CreateWindowDeviceAndSwapChain( createParms, GAME_NAME ) )
|
||||
#else
|
||||
window = SDL_CreateWindow( GAME_NAME,
|
||||
windowPos,
|
||||
windowPos,
|
||||
parms.width, parms.height, flags );
|
||||
// DG end
|
||||
|
||||
vkcontext.sdlWindow = window;
|
||||
|
||||
if( !window )
|
||||
#endif
|
||||
{
|
||||
common->DPrintf( "Couldn't set Vulkan mode %d/%d/%d: %s",
|
||||
channelcolorbits, tdepthbits, tstencilbits, SDL_GetError() );
|
||||
continue;
|
||||
}
|
||||
vkcontext.sdlWindow = window;
|
||||
|
||||
// RB begin
|
||||
SDL_GetWindowSize( window, &glConfig.nativeScreenWidth, &glConfig.nativeScreenHeight );
|
||||
// RB end
|
||||
|
||||
glConfig.isFullscreen = ( SDL_GetWindowFlags( window ) & SDL_WINDOW_FULLSCREEN ) == SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
#if !defined( USE_NVRHI )
|
||||
common->Printf( "Using %d color bits, %d depth, %d stencil display\n",
|
||||
channelcolorbits, tdepthbits, tstencilbits );
|
||||
|
||||
glConfig.colorBits = tcolorbits;
|
||||
glConfig.depthBits = tdepthbits;
|
||||
glConfig.stencilBits = tstencilbits;
|
||||
#endif
|
||||
|
||||
// RB begin
|
||||
glConfig.displayFrequency = 60;
|
||||
|
@ -474,6 +536,19 @@ bool VKimp_SetScreenParms( glimpParms_t parms )
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
void DeviceManager::Shutdown()
|
||||
{
|
||||
DestroyDeviceAndSwapChain();
|
||||
|
||||
// destroy window
|
||||
VKimp_Shutdown();
|
||||
|
||||
// restore gamma
|
||||
//VKimp_RestoreGamma();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
===================
|
||||
VKimp_Shutdown
|
||||
|
|
Loading…
Reference in a new issue