mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 10:38:53 +00:00
Sync NVRHI branch by SP
This commit is contained in:
parent
ccd5086d20
commit
51d317543c
48 changed files with 2074 additions and 2398 deletions
|
@ -74,11 +74,11 @@ option(USE_SYSTEM_RAPIDJSON
|
|||
option(USE_NVRHI
|
||||
"Use the NVRHI rendering library" ON)
|
||||
|
||||
option(USE_DX11 "Use DirectX 11" OFF)
|
||||
option(USE_DX12
|
||||
"Use DirectX 12" ON)
|
||||
|
||||
option(USE_DX12 "Use DirectX 12" ON)
|
||||
|
||||
option(USE_NVRHI_VULKAN "Use Vulkan" OFF)
|
||||
option(USE_NVRHI_VULKAN
|
||||
"Use Vulkan" ON)
|
||||
|
||||
set(CPU_TYPE "" CACHE STRING "When set, passes this string as CPU-ID which will be embedded into the binary.")
|
||||
|
||||
|
@ -292,6 +292,7 @@ elseif(MSVC)
|
|||
# endif()
|
||||
|
||||
add_definitions(-DWIN32
|
||||
-DNOMINMAX
|
||||
-D_WINDOWS
|
||||
-D_CRT_SECURE_NO_DEPRECATE
|
||||
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||
|
@ -453,7 +454,51 @@ if(USE_VULKAN)
|
|||
elseif(WIN32)
|
||||
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)
|
||||
endif()
|
||||
elseif(USE_NVRHI_VULKAN)
|
||||
# RB: moved this above the general Vulkan part so glslang does not include Vulkan SDK headers
|
||||
# which causes all kinds of weird segmentation faults because struct sizes don't match
|
||||
|
||||
# SRS - Set default VULKAN_SDK location if environment variable not defined on OSX
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT DEFINED ENV{VULKAN_SDK})
|
||||
if(NOT USE_MoltenVK)
|
||||
# SRS - Vulkan SDK installer copies standard vulkan headers and libs to /usr/local on OSX
|
||||
set(ENV{VULKAN_SDK} /usr/local)
|
||||
else()
|
||||
message(FATAL_ERROR "Must define VULKAN_SDK location if USE_MoltenVK option enabled!")
|
||||
endif()
|
||||
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
|
||||
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(-DVULKAN_USE_PLATFORM_SDL)
|
||||
elseif(WIN32)
|
||||
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)
|
||||
endif()
|
||||
else()
|
||||
|
||||
if(USE_SYSTEM_LIBGLEW)
|
||||
|
@ -1035,7 +1080,6 @@ file(GLOB_RECURSE WIN32_INCLUDES sys/win32/*.h)
|
|||
#file(GLOB_RECURSE WIN32_SOURCES sys/win32/*.cpp)
|
||||
|
||||
set(WIN32_SOURCES
|
||||
sys/win32/DeviceManager_DX12.cpp
|
||||
sys/win32/win_glimp.cpp
|
||||
sys/win32/win_input.cpp
|
||||
sys/win32/win_main.cpp
|
||||
|
@ -1044,6 +1088,14 @@ set(WIN32_SOURCES
|
|||
sys/win32/win_syscon.cpp
|
||||
sys/win32/win_taskkeyhook.cpp
|
||||
sys/win32/win_wndproc.cpp)
|
||||
|
||||
if(USE_DX12)
|
||||
list(APPEND WIN32_SOURCES sys/win32/DeviceManager_DX12.cpp)
|
||||
endif()
|
||||
|
||||
if(USE_NVRHI_VULKAN)
|
||||
list(APPEND WIN32_SOURCES sys/win32/DeviceManager_VK.cpp)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
list(APPEND WIN32_SOURCES sys/win32/win_cpu.cpp)
|
||||
|
@ -1675,16 +1727,16 @@ if(MSVC)
|
|||
#endforeach()
|
||||
|
||||
set_source_files_properties(
|
||||
${RBDOOM3_PRECOMPILED_SOURCES}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/Yuprecompiled.h"
|
||||
OBJECT_DEPENDS "precompiled.pch"
|
||||
${RBDOOM3_PRECOMPILED_SOURCES}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/Yuprecompiled.h"
|
||||
OBJECT_DEPENDS "precompiled.pch"
|
||||
)
|
||||
|
||||
set_source_files_properties(framework/precompiled.cpp
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/Ycprecompiled.h"
|
||||
OBJECT_OUTPUTS "precompiled.pch"
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "/Ycprecompiled.h"
|
||||
OBJECT_OUTPUTS "precompiled.pch"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -1705,12 +1757,9 @@ if(MSVC)
|
|||
add_executable(RBDoom3BFG WIN32 ${RBDOOM3_INCLUDES} ${RBDOOM3_SOURCES})
|
||||
|
||||
add_dependencies(RBDoom3BFG idlib)
|
||||
|
||||
if(USE_DX12)
|
||||
add_dependencies(RBDoom3BFG nvrhi_d3d12)
|
||||
endif()
|
||||
|
||||
if(USE_DX11)
|
||||
add_dependencies(RBDoom3BFG nvrhi_d3d11)
|
||||
add_dependencies(RBDoom3BFG nvrhi_d3d12)
|
||||
endif()
|
||||
|
||||
if(USE_NVRHI_VULKAN)
|
||||
|
@ -1944,7 +1993,6 @@ if(USE_DX11)
|
|||
endif()
|
||||
|
||||
if(USE_DX12)
|
||||
#target_sources(RBDoom3BFG PRIVATE src/app/dx12/DeviceManager_DX12.cpp)
|
||||
target_compile_definitions(RBDoom3BFG PUBLIC USE_DX12=1)
|
||||
target_link_libraries(RBDoom3BFG nvrhi_d3d12)
|
||||
endif()
|
||||
|
@ -1954,7 +2002,6 @@ if(USE_DXIL_ON_DX12)
|
|||
endif()
|
||||
|
||||
if(USE_NVRHI_VULKAN)
|
||||
#target_sources(RBDoom3BFG PRIVATE src/app/vulkan/DeviceManager_VK.cpp)
|
||||
target_compile_definitions(RBDoom3BFG PUBLIC USE_VK=1)
|
||||
target_link_libraries(RBDoom3BFG nvrhi_vk)
|
||||
endif()
|
||||
|
|
2
neo/extern/nvrhi
vendored
2
neo/extern/nvrhi
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 78da052111878d8d7552205f21551d030e71213c
|
||||
Subproject commit 43d74475fdc369c6a31b25efe31c3b7f99a81807
|
|
@ -99,13 +99,9 @@ const int MAX_EXPRESSION_REGISTERS = 4096;
|
|||
#elif defined(USE_VULKAN)
|
||||
#include "../renderer/Vulkan/qvk.h"
|
||||
#else
|
||||
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
// FIMXE remove GL with NVRHI
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
||||
#include "../renderer/Cinematic.h"
|
||||
#include "../renderer/Material.h"
|
||||
#include "../renderer/BufferObject.h"
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
|
||||
#include "BindingCache.h"
|
||||
|
||||
BindingCache::BindingCache()
|
||||
: device( nullptr )
|
||||
, bindingSets()
|
||||
, bindingHash()
|
||||
, mutex()
|
||||
{
|
||||
}
|
||||
|
||||
void BindingCache::Init( nvrhi::IDevice* _device )
|
||||
{
|
||||
device = _device;
|
||||
|
@ -39,7 +47,6 @@ nvrhi::BindingSetHandle BindingCache::GetCachedBindingSet( const nvrhi::BindingS
|
|||
|
||||
nvrhi::BindingSetHandle BindingCache::GetOrCreateBindingSet( const nvrhi::BindingSetDesc& desc, nvrhi::IBindingLayout* layout )
|
||||
{
|
||||
#if 1
|
||||
size_t hash = 0;
|
||||
nvrhi::hash_combine( hash, desc );
|
||||
nvrhi::hash_combine( hash, layout );
|
||||
|
@ -77,9 +84,6 @@ nvrhi::BindingSetHandle BindingCache::GetOrCreateBindingSet( const nvrhi::Bindin
|
|||
}
|
||||
|
||||
return result;
|
||||
#else
|
||||
return device->createBindingSet( desc, layout );
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindingCache::Clear()
|
||||
|
|
|
@ -33,7 +33,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
class BindingCache
|
||||
{
|
||||
public:
|
||||
BindingCache() {}
|
||||
BindingCache();
|
||||
|
||||
void Init( nvrhi::IDevice* _device );
|
||||
void Clear();
|
||||
|
|
|
@ -491,16 +491,26 @@ public:
|
|||
return ( void* )sampler.Get();
|
||||
}
|
||||
|
||||
void* GetSampler( nvrhi::IDevice* device )
|
||||
{
|
||||
if( !sampler )
|
||||
{
|
||||
sampler = device->createSampler( samplerDesc );
|
||||
}
|
||||
|
||||
return ( void* )sampler;
|
||||
}
|
||||
|
||||
nvrhi::SamplerDesc* GetSamplerDesc()
|
||||
{
|
||||
return &samplerDesc;
|
||||
}
|
||||
|
||||
void SetSampler( nvrhi::SamplerHandle _sampler )
|
||||
{
|
||||
sampler = _sampler;
|
||||
}
|
||||
|
||||
const nvrhi::SamplerDesc& GetSamplerDesc()
|
||||
{
|
||||
return samplerDesc;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class idImageManager;
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
extern idCVar r_showBuffers;
|
||||
|
||||
//static const GLenum bufferUsage = GL_STATIC_DRAW;
|
||||
static const GLenum bufferUsage = GL_DYNAMIC_DRAW;
|
||||
|
||||
extern DeviceManager* deviceManager;
|
||||
|
||||
/*
|
||||
|
@ -109,17 +106,18 @@ bool idVertexBuffer::AllocBufferObject( const void* data, int allocSize, bufferU
|
|||
nvrhi::BufferDesc vertexBufferDesc;
|
||||
vertexBufferDesc.byteSize = numBytes;
|
||||
vertexBufferDesc.isVertexBuffer = true;
|
||||
vertexBufferDesc.debugName = "VertexBuffer";
|
||||
|
||||
if( usage == BU_DYNAMIC )
|
||||
{
|
||||
vertexBufferDesc.initialState = nvrhi::ResourceStates::CopyDest;
|
||||
vertexBufferDesc.cpuAccess = nvrhi::CpuAccessMode::Write;
|
||||
vertexBufferDesc.debugName = "Mapped idDrawVert vertex buffer";
|
||||
}
|
||||
else
|
||||
{
|
||||
vertexBufferDesc.initialState = nvrhi::ResourceStates::Common;
|
||||
vertexBufferDesc.keepInitialState = true;
|
||||
vertexBufferDesc.debugName = "Static idDrawVert vertex buffer";
|
||||
}
|
||||
|
||||
bufferHandle = deviceManager->GetDevice()->createBuffer( vertexBufferDesc );
|
||||
|
@ -392,7 +390,6 @@ void idIndexBuffer::Update( const void* data, int updateSize, int offset, bool i
|
|||
|
||||
if( usage == BU_DYNAMIC )
|
||||
{
|
||||
void* buffer = deviceManager->GetDevice()->mapBuffer( bufferHandle, nvrhi::CpuAccessMode::Write );
|
||||
CopyBuffer( ( byte* )buffer + offset, ( const byte* )data, numBytes );
|
||||
}
|
||||
else
|
||||
|
@ -519,12 +516,13 @@ bool idUniformBuffer::AllocBufferObject( const void* data, int allocSize, buffer
|
|||
|
||||
if( usage == BU_DYNAMIC )
|
||||
{
|
||||
bufferDesc.debugName = "ConstantBuffer";
|
||||
bufferDesc.debugName = "Mapped ConstantBuffer";
|
||||
bufferDesc.initialState = nvrhi::ResourceStates::CopyDest;
|
||||
bufferDesc.cpuAccess = nvrhi::CpuAccessMode::Write;
|
||||
}
|
||||
else
|
||||
{
|
||||
bufferDesc.debugName = "Static ConstantBuffer";
|
||||
bufferDesc.keepInitialState = true;
|
||||
}
|
||||
|
||||
|
@ -568,7 +566,6 @@ void idUniformBuffer::Update( const void* data, int updateSize, int offset, bool
|
|||
|
||||
if( usage == BU_DYNAMIC )
|
||||
{
|
||||
void* buffer = deviceManager->GetDevice()->mapBuffer( bufferHandle, nvrhi::CpuAccessMode::Write );
|
||||
CopyBuffer( ( byte* )buffer + offset, ( const byte* )data, numBytes );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -101,7 +101,8 @@ void Framebuffer::Shutdown()
|
|||
|
||||
void Framebuffer::ResizeFramebuffers()
|
||||
{
|
||||
tr.backend.pipelineCache.Clear();
|
||||
tr.backend.ClearCaches();
|
||||
|
||||
uint32_t backBufferCount = deviceManager->GetBackBufferCount();
|
||||
globalFramebuffers.swapFramebuffers.Resize( backBufferCount );
|
||||
globalFramebuffers.swapFramebuffers.SetNum( backBufferCount );
|
||||
|
|
|
@ -271,7 +271,7 @@ void idImage::AllocImage()
|
|||
break;
|
||||
|
||||
case FMT_R8:
|
||||
format = nvrhi::Format::R8_UINT;
|
||||
format = nvrhi::Format::R8_UNORM;
|
||||
break;
|
||||
|
||||
case FMT_DXT1:
|
||||
|
@ -385,54 +385,49 @@ void idImage::AllocImage()
|
|||
.setSampleCount( opts.samples )
|
||||
.setMipLevels( opts.numLevels );
|
||||
|
||||
#if defined( USE_DX12 )
|
||||
if( opts.colorFormat == CFM_GREEN_ALPHA )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 5; // ONE
|
||||
textureDesc.componentMapping.bits.g = 5; // ONE
|
||||
textureDesc.componentMapping.bits.b = 5; // ONE
|
||||
textureDesc.componentMapping.bits.a = 1; // G
|
||||
textureDesc.componentMapping.r = nvrhi::ComponentSwizzle::One;
|
||||
textureDesc.componentMapping.g = nvrhi::ComponentSwizzle::One;
|
||||
textureDesc.componentMapping.b = nvrhi::ComponentSwizzle::One;
|
||||
textureDesc.componentMapping.a = nvrhi::ComponentSwizzle::Green;
|
||||
}
|
||||
else if( opts.format == FMT_LUM8 )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 0; // R
|
||||
textureDesc.componentMapping.bits.g = 0; // R
|
||||
textureDesc.componentMapping.bits.b = 0; // R
|
||||
textureDesc.componentMapping.bits.a = 5; // ONE
|
||||
textureDesc.componentMapping.r = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.g = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.b = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.a = nvrhi::ComponentSwizzle::One;
|
||||
}
|
||||
else if( opts.format == FMT_L8A8 )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 0; // R
|
||||
textureDesc.componentMapping.bits.g = 0; // R
|
||||
textureDesc.componentMapping.bits.b = 0; // R
|
||||
textureDesc.componentMapping.bits.a = 1; // G
|
||||
textureDesc.componentMapping.r = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.g = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.b = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.a = nvrhi::ComponentSwizzle::Green;
|
||||
}
|
||||
else if( opts.format == FMT_ALPHA )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 5; // ONE
|
||||
textureDesc.componentMapping.bits.g = 5; // ONE
|
||||
textureDesc.componentMapping.bits.b = 5; // ONE
|
||||
textureDesc.componentMapping.bits.a = 0; // R
|
||||
textureDesc.componentMapping.r = nvrhi::ComponentSwizzle::One;
|
||||
textureDesc.componentMapping.g = nvrhi::ComponentSwizzle::One;
|
||||
textureDesc.componentMapping.b = nvrhi::ComponentSwizzle::One;
|
||||
textureDesc.componentMapping.a = nvrhi::ComponentSwizzle::Red;
|
||||
}
|
||||
else if( opts.format == FMT_INT8 )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 0; // R
|
||||
textureDesc.componentMapping.bits.g = 0; // R
|
||||
textureDesc.componentMapping.bits.b = 0; // R
|
||||
textureDesc.componentMapping.bits.a = 0; // R
|
||||
textureDesc.componentMapping.r = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.g = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.b = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.a = nvrhi::ComponentSwizzle::Red;
|
||||
}
|
||||
else if( opts.format == FMT_R11G11B10F )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 0; // R
|
||||
textureDesc.componentMapping.bits.g = 1; // G
|
||||
textureDesc.componentMapping.bits.b = 2; // B
|
||||
textureDesc.componentMapping.bits.a = 5; // ONE
|
||||
textureDesc.componentMapping.r = nvrhi::ComponentSwizzle::Red;
|
||||
textureDesc.componentMapping.g = nvrhi::ComponentSwizzle::Green;
|
||||
textureDesc.componentMapping.b = nvrhi::ComponentSwizzle::Blue;
|
||||
textureDesc.componentMapping.a = nvrhi::ComponentSwizzle::One;
|
||||
}
|
||||
|
||||
#elif defined( USE_VULKAN )
|
||||
// TODO
|
||||
#endif
|
||||
|
||||
if( opts.isRenderTarget )
|
||||
{
|
||||
//textureDesc.keepInitialState = true;
|
||||
|
|
|
@ -47,13 +47,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "../RenderCommon.h"
|
||||
#include "../RenderBackend.h"
|
||||
#include "../../framework/Common_local.h"
|
||||
#include "renderer/RenderPass.h"
|
||||
|
||||
#include "../../imgui/imgui.h"
|
||||
|
||||
#include <sys/DeviceManager.h>
|
||||
|
||||
#include "nvrhi/utils.h"
|
||||
#include <sys/DeviceManager.h>
|
||||
|
||||
idCVar r_drawFlickerBox( "r_drawFlickerBox", "0", CVAR_RENDERER | CVAR_BOOL, "visual test for dropping frames" );
|
||||
idCVar stereoRender_warp( "stereoRender_warp", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use the optical warping renderprog instead of stereoDeGhost" );
|
||||
|
@ -68,14 +65,9 @@ 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" );
|
||||
|
||||
static int swapIndex; // 0 or 1 into renderSync
|
||||
static GLsync renderSync[2];
|
||||
|
||||
void GLimp_SwapBuffers();
|
||||
void RB_SetMVP( const idRenderMatrix& mvp );
|
||||
|
||||
glContext_t glcontext;
|
||||
|
||||
class NvrhiContext
|
||||
{
|
||||
public:
|
||||
|
@ -111,36 +103,6 @@ For ARB_debug_output
|
|||
static void CALLBACK DebugCallback( unsigned int source, unsigned int type,
|
||||
unsigned int id, unsigned int severity, int length, const char* msg, const void* userParam )
|
||||
{
|
||||
char s[1024];
|
||||
|
||||
// it probably isn't safe to do an idLib::Printf at this point
|
||||
|
||||
const char* severityStr = "Severity: Unkown";
|
||||
switch( severity )
|
||||
{
|
||||
case GL_DEBUG_SEVERITY_HIGH:
|
||||
severityStr = "Severity: High";
|
||||
break;
|
||||
|
||||
case GL_DEBUG_SEVERITY_MEDIUM:
|
||||
severityStr = "Severity: Medium";
|
||||
break;
|
||||
|
||||
case GL_DEBUG_SEVERITY_LOW:
|
||||
severityStr = "Severity: High";
|
||||
break;
|
||||
}
|
||||
|
||||
idStr::snPrintf( s, sizeof( s ), "[OpenGL] Debug: [ %s ] Code %d, %d : '%s'\n", severityStr, source, type, msg );
|
||||
|
||||
// RB: printf should be thread safe on Linux
|
||||
#if defined(_WIN32)
|
||||
OutputDebugString( s );
|
||||
OutputDebugString( "\n" );
|
||||
#else
|
||||
printf( "%s\n", s );
|
||||
#endif
|
||||
// RB end
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,295 +114,6 @@ R_CheckPortableExtensions
|
|||
// RB: replaced QGL with GLEW
|
||||
static void R_CheckPortableExtensions()
|
||||
{
|
||||
glConfig.glVersion = atof( glConfig.version_string );
|
||||
const char* badVideoCard = idLocalization::GetString( "#str_06780" );
|
||||
if( glConfig.glVersion < 2.0f )
|
||||
{
|
||||
idLib::FatalError( "%s", badVideoCard );
|
||||
}
|
||||
|
||||
if( idStr::Icmpn( glConfig.renderer_string, "ATI ", 4 ) == 0 || idStr::Icmpn( glConfig.renderer_string, "AMD ", 4 ) == 0 )
|
||||
{
|
||||
glConfig.vendor = VENDOR_AMD;
|
||||
}
|
||||
else if( idStr::Icmpn( glConfig.renderer_string, "NVIDIA", 6 ) == 0 )
|
||||
{
|
||||
glConfig.vendor = VENDOR_NVIDIA;
|
||||
}
|
||||
else if( idStr::Icmpn( glConfig.renderer_string, "Intel", 5 ) == 0 )
|
||||
{
|
||||
glConfig.vendor = VENDOR_INTEL;
|
||||
}
|
||||
|
||||
// RB: Mesa support
|
||||
if( idStr::Icmpn( glConfig.renderer_string, "Mesa", 4 ) == 0 || idStr::Icmpn( glConfig.renderer_string, "X.org", 5 ) == 0 || idStr::Icmpn( glConfig.renderer_string, "Gallium", 7 ) == 0 ||
|
||||
strcmp( glConfig.vendor_string, "X.Org" ) == 0 ||
|
||||
idStr::Icmpn( glConfig.renderer_string, "llvmpipe", 8 ) == 0 )
|
||||
{
|
||||
if( glConfig.driverType == GLDRV_OPENGL32_CORE_PROFILE )
|
||||
{
|
||||
glConfig.driverType = GLDRV_OPENGL_MESA_CORE_PROFILE;
|
||||
}
|
||||
else
|
||||
{
|
||||
glConfig.driverType = GLDRV_OPENGL_MESA;
|
||||
}
|
||||
}
|
||||
// RB end
|
||||
|
||||
// GL_ARB_multitexture
|
||||
if( glConfig.driverType != GLDRV_OPENGL3X )
|
||||
{
|
||||
glConfig.multitextureAvailable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
glConfig.multitextureAvailable = GLEW_ARB_multitexture != 0;
|
||||
}
|
||||
|
||||
// GL_EXT_direct_state_access
|
||||
glConfig.directStateAccess = GLEW_EXT_direct_state_access != 0;
|
||||
|
||||
|
||||
// GL_ARB_texture_compression + GL_S3_s3tc
|
||||
// DRI drivers may have GL_ARB_texture_compression but no GL_EXT_texture_compression_s3tc
|
||||
if( glConfig.driverType == GLDRV_OPENGL_MESA_CORE_PROFILE )
|
||||
{
|
||||
glConfig.textureCompressionAvailable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
glConfig.textureCompressionAvailable = GLEW_ARB_texture_compression != 0 && GLEW_EXT_texture_compression_s3tc != 0;
|
||||
}
|
||||
// GL_EXT_texture_filter_anisotropic
|
||||
glConfig.anisotropicFilterAvailable = GLEW_EXT_texture_filter_anisotropic != 0;
|
||||
if( glConfig.anisotropicFilterAvailable )
|
||||
{
|
||||
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.maxTextureAnisotropy );
|
||||
common->Printf( " maxTextureAnisotropy: %f\n", glConfig.maxTextureAnisotropy );
|
||||
}
|
||||
else
|
||||
{
|
||||
glConfig.maxTextureAnisotropy = 1;
|
||||
}
|
||||
|
||||
// GL_EXT_texture_lod_bias
|
||||
// The actual extension is broken as specificed, storing the state in the texture unit instead
|
||||
// of the texture object. The behavior in GL 1.4 is the behavior we use.
|
||||
glConfig.textureLODBiasAvailable = ( glConfig.glVersion >= 1.4 || GLEW_EXT_texture_lod_bias != 0 );
|
||||
if( glConfig.textureLODBiasAvailable )
|
||||
{
|
||||
common->Printf( "...using %s\n", "GL_EXT_texture_lod_bias" );
|
||||
}
|
||||
else
|
||||
{
|
||||
common->Printf( "X..%s not found\n", "GL_EXT_texture_lod_bias" );
|
||||
}
|
||||
|
||||
// GL_ARB_seamless_cube_map
|
||||
glConfig.seamlessCubeMapAvailable = GLEW_ARB_seamless_cube_map != 0;
|
||||
r_useSeamlessCubeMap.SetModified(); // the CheckCvars() next frame will enable / disable it
|
||||
|
||||
// GL_ARB_vertex_buffer_object
|
||||
if( glConfig.driverType == GLDRV_OPENGL_MESA_CORE_PROFILE )
|
||||
{
|
||||
glConfig.vertexBufferObjectAvailable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
glConfig.vertexBufferObjectAvailable = GLEW_ARB_vertex_buffer_object != 0;
|
||||
}
|
||||
|
||||
// GL_ARB_map_buffer_range, map a section of a buffer object's data store
|
||||
//if( glConfig.driverType == GLDRV_OPENGL_MESA_CORE_PROFILE )
|
||||
//{
|
||||
// glConfig.mapBufferRangeAvailable = true;
|
||||
//}
|
||||
//else
|
||||
{
|
||||
glConfig.mapBufferRangeAvailable = GLEW_ARB_map_buffer_range != 0;
|
||||
}
|
||||
|
||||
// GL_ARB_vertex_array_object
|
||||
//if( glConfig.driverType == GLDRV_OPENGL_MESA_CORE_PROFILE )
|
||||
//{
|
||||
// glConfig.vertexArrayObjectAvailable = true;
|
||||
//}
|
||||
//else
|
||||
{
|
||||
glConfig.vertexArrayObjectAvailable = GLEW_ARB_vertex_array_object != 0;
|
||||
}
|
||||
|
||||
// GL_ARB_draw_elements_base_vertex
|
||||
glConfig.drawElementsBaseVertexAvailable = GLEW_ARB_draw_elements_base_vertex != 0;
|
||||
|
||||
// GL_ARB_vertex_program / GL_ARB_fragment_program
|
||||
glConfig.fragmentProgramAvailable = GLEW_ARB_fragment_program != 0;
|
||||
//if( glConfig.fragmentProgramAvailable )
|
||||
{
|
||||
glGetIntegerv( GL_MAX_TEXTURE_COORDS, ( GLint* )&glConfig.maxTextureCoords );
|
||||
glGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS, ( GLint* )&glConfig.maxTextureImageUnits );
|
||||
}
|
||||
|
||||
// GLSL, core in OpenGL > 2.0
|
||||
glConfig.glslAvailable = ( glConfig.glVersion >= 2.0f );
|
||||
|
||||
// GL_ARB_uniform_buffer_object
|
||||
glConfig.uniformBufferAvailable = GLEW_ARB_uniform_buffer_object != 0;
|
||||
if( glConfig.uniformBufferAvailable )
|
||||
{
|
||||
glGetIntegerv( GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, ( GLint* )&glConfig.uniformBufferOffsetAlignment );
|
||||
if( glConfig.uniformBufferOffsetAlignment < 256 )
|
||||
{
|
||||
glConfig.uniformBufferOffsetAlignment = 256;
|
||||
}
|
||||
}
|
||||
// RB: make GPU skinning optional for weak OpenGL drivers
|
||||
glConfig.gpuSkinningAvailable = glConfig.uniformBufferAvailable && ( glConfig.driverType == GLDRV_OPENGL3X || glConfig.driverType == GLDRV_OPENGL32_CORE_PROFILE || glConfig.driverType == GLDRV_OPENGL32_COMPATIBILITY_PROFILE );
|
||||
|
||||
// ATI_separate_stencil / OpenGL 2.0 separate stencil
|
||||
glConfig.twoSidedStencilAvailable = ( glConfig.glVersion >= 2.0f ) || GLEW_ATI_separate_stencil != 0;
|
||||
|
||||
// GL_EXT_depth_bounds_test
|
||||
glConfig.depthBoundsTestAvailable = GLEW_EXT_depth_bounds_test != 0;
|
||||
|
||||
// GL_ARB_sync
|
||||
glConfig.syncAvailable = GLEW_ARB_sync &&
|
||||
// as of 5/24/2012 (driver version 15.26.12.64.2761) sync objects
|
||||
// do not appear to work for the Intel HD 4000 graphics
|
||||
( glConfig.vendor != VENDOR_INTEL || r_skipIntelWorkarounds.GetBool() );
|
||||
|
||||
// GL_ARB_occlusion_query
|
||||
glConfig.occlusionQueryAvailable = GLEW_ARB_occlusion_query != 0;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// SRS - DSA not available in Apple OpenGL 4.1, but enable for OSX anyways since elapsed time query will be used to get timing info instead
|
||||
glConfig.timerQueryAvailable = ( GLEW_ARB_timer_query != 0 || GLEW_EXT_timer_query != 0 );
|
||||
#else
|
||||
// GL_ARB_timer_query using the DSA interface
|
||||
glConfig.timerQueryAvailable = ( GLEW_ARB_direct_state_access != 0 && GLEW_ARB_timer_query != 0 );
|
||||
#endif
|
||||
|
||||
// GREMEDY_string_marker
|
||||
glConfig.gremedyStringMarkerAvailable = GLEW_GREMEDY_string_marker != 0;
|
||||
if( glConfig.gremedyStringMarkerAvailable )
|
||||
{
|
||||
common->Printf( "...using %s\n", "GL_GREMEDY_string_marker" );
|
||||
}
|
||||
else
|
||||
{
|
||||
common->Printf( "X..%s not found\n", "GL_GREMEDY_string_marker" );
|
||||
}
|
||||
|
||||
// KHR_debug
|
||||
glConfig.khronosDebugAvailable = GLEW_KHR_debug != 0;
|
||||
if( glConfig.khronosDebugAvailable )
|
||||
{
|
||||
common->Printf( "...using %s\n", "GLEW_KHR_debug" );
|
||||
}
|
||||
else
|
||||
{
|
||||
common->Printf( "X..%s not found\n", "GLEW_KHR_debug" );
|
||||
}
|
||||
|
||||
// GL_ARB_framebuffer_object
|
||||
glConfig.framebufferObjectAvailable = GLEW_ARB_framebuffer_object != 0;
|
||||
if( glConfig.framebufferObjectAvailable )
|
||||
{
|
||||
glGetIntegerv( GL_MAX_RENDERBUFFER_SIZE, &glConfig.maxRenderbufferSize );
|
||||
glGetIntegerv( GL_MAX_COLOR_ATTACHMENTS, &glConfig.maxColorAttachments );
|
||||
|
||||
common->Printf( "...using %s\n", "GL_ARB_framebuffer_object" );
|
||||
}
|
||||
else
|
||||
{
|
||||
common->Printf( "X..%s not found\n", "GL_ARB_framebuffer_object" );
|
||||
}
|
||||
|
||||
// GL_EXT_framebuffer_blit
|
||||
glConfig.framebufferBlitAvailable = GLEW_EXT_framebuffer_blit != 0;
|
||||
if( glConfig.framebufferBlitAvailable )
|
||||
{
|
||||
common->Printf( "...using %s\n", "GL_EXT_framebuffer_blit" );
|
||||
}
|
||||
else
|
||||
{
|
||||
common->Printf( "X..%s not found\n", "GL_EXT_framebuffer_blit" );
|
||||
}
|
||||
|
||||
// GL_ARB_debug_output
|
||||
glConfig.debugOutputAvailable = GLEW_ARB_debug_output != 0;
|
||||
if( glConfig.debugOutputAvailable )
|
||||
{
|
||||
if( r_debugContext.GetInteger() >= 1 )
|
||||
{
|
||||
glDebugMessageCallbackARB( ( GLDEBUGPROCARB ) DebugCallback, NULL );
|
||||
}
|
||||
if( r_debugContext.GetInteger() >= 2 )
|
||||
{
|
||||
// force everything to happen in the main thread instead of in a separate driver thread
|
||||
glEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB );
|
||||
}
|
||||
if( r_debugContext.GetInteger() >= 3 )
|
||||
{
|
||||
// enable all the low priority messages
|
||||
glDebugMessageControlARB( GL_DONT_CARE,
|
||||
GL_DONT_CARE,
|
||||
GL_DEBUG_SEVERITY_LOW_ARB,
|
||||
0, NULL, true );
|
||||
}
|
||||
}
|
||||
|
||||
// GL_ARB_multitexture
|
||||
if( !glConfig.multitextureAvailable )
|
||||
{
|
||||
idLib::Error( "GL_ARB_multitexture not available" );
|
||||
}
|
||||
// GL_ARB_texture_compression + GL_EXT_texture_compression_s3tc
|
||||
if( !glConfig.textureCompressionAvailable )
|
||||
{
|
||||
idLib::Error( "GL_ARB_texture_compression or GL_EXT_texture_compression_s3tc not available" );
|
||||
}
|
||||
// GL_ARB_vertex_buffer_object
|
||||
if( !glConfig.vertexBufferObjectAvailable )
|
||||
{
|
||||
idLib::Error( "GL_ARB_vertex_buffer_object not available" );
|
||||
}
|
||||
// GL_ARB_map_buffer_range
|
||||
if( !glConfig.mapBufferRangeAvailable )
|
||||
{
|
||||
idLib::Error( "GL_ARB_map_buffer_range not available" );
|
||||
}
|
||||
// GL_ARB_vertex_array_object
|
||||
if( !glConfig.vertexArrayObjectAvailable )
|
||||
{
|
||||
idLib::Error( "GL_ARB_vertex_array_object not available" );
|
||||
}
|
||||
// GL_ARB_draw_elements_base_vertex
|
||||
if( !glConfig.drawElementsBaseVertexAvailable )
|
||||
{
|
||||
idLib::Error( "GL_ARB_draw_elements_base_vertex not available" );
|
||||
}
|
||||
// GL_ARB_vertex_program / GL_ARB_fragment_program
|
||||
//if( !glConfig.fragmentProgramAvailable )
|
||||
//{
|
||||
// idLib::Warning( "GL_ARB_fragment_program not available" );
|
||||
//}
|
||||
// GLSL
|
||||
if( !glConfig.glslAvailable )
|
||||
{
|
||||
idLib::Error( "GLSL not available" );
|
||||
}
|
||||
// GL_ARB_uniform_buffer_object
|
||||
if( !glConfig.uniformBufferAvailable )
|
||||
{
|
||||
idLib::Error( "GL_ARB_uniform_buffer_object not available" );
|
||||
}
|
||||
// GL_EXT_stencil_two_side
|
||||
if( !glConfig.twoSidedStencilAvailable )
|
||||
{
|
||||
idLib::Error( "GL_ATI_separate_stencil not available" );
|
||||
}
|
||||
}
|
||||
// RB end
|
||||
|
||||
|
@ -492,7 +165,6 @@ void idRenderBackend::Init()
|
|||
commonPasses.Init( deviceManager->GetDevice() );
|
||||
hiZGenPass = nullptr;
|
||||
ssaoPass = nullptr;
|
||||
//fowardShadingPass.Init( deviceManager->GetDevice() );
|
||||
|
||||
tr.SetInitialized();
|
||||
|
||||
|
@ -504,7 +176,6 @@ void idRenderBackend::Init()
|
|||
// allocate the vertex array range or vertex objects
|
||||
commandList->open();
|
||||
vertexCache.Init( glConfig.uniformBufferOffsetAlignment, commandList );
|
||||
renderProgManager.CommitConstantBuffer( commandList );
|
||||
commandList->close();
|
||||
deviceManager->GetDevice()->executeCommandList( commandList );
|
||||
|
||||
|
@ -537,6 +208,9 @@ idRenderBackend::DrawElementsWithCounters
|
|||
*/
|
||||
void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
||||
{
|
||||
// Only update the constant buffer if it was updated at all.
|
||||
renderProgManager.CommitConstantBuffer( commandList );
|
||||
|
||||
// Get vertex buffer
|
||||
const vertCacheHandle_t vbHandle = surf->ambientCache;
|
||||
idVertexBuffer* vertexBuffer;
|
||||
|
@ -601,34 +275,24 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
changeState = true;
|
||||
}
|
||||
|
||||
GetCurrentBindingLayout();
|
||||
|
||||
// RB: for debugging
|
||||
int program = renderProgManager.CurrentProgram();
|
||||
int bindingLayoutType = renderProgManager.BindingLayoutType();
|
||||
auto& info = renderProgManager.GetProgramInfo( program );
|
||||
/*
|
||||
if( info.cs )
|
||||
{
|
||||
renderLog.OpenBlock( info.cs->getDesc().debugName.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
renderLog.OpenBlock( info.ps->getDesc().debugName.c_str() );
|
||||
}
|
||||
*/
|
||||
|
||||
for( int i = 0; i < info.bindingLayouts->Num(); i++ )
|
||||
idStaticList<nvrhi::BindingLayoutHandle, nvrhi::c_MaxBindingLayouts>* layouts
|
||||
= renderProgManager.GetBindingLayout( bindingLayoutType );
|
||||
|
||||
GetCurrentBindingLayout( bindingLayoutType );
|
||||
|
||||
for( int i = 0; i < layouts->Num(); i++ )
|
||||
{
|
||||
if( !currentBindingSets[i] || *currentBindingSets[i]->getDesc() != pendingBindingSetDescs[i] )
|
||||
if( !currentBindingSets[i] || *currentBindingSets[i]->getDesc() != pendingBindingSetDescs[bindingLayoutType][i] )
|
||||
{
|
||||
currentBindingSets[i] = bindingCache.GetOrCreateBindingSet( pendingBindingSetDescs[i], ( *info.bindingLayouts )[i] );
|
||||
currentBindingSets[i] = bindingCache.GetOrCreateBindingSet( pendingBindingSetDescs[bindingLayoutType][i], ( *layouts )[i] );
|
||||
changeState = true;
|
||||
}
|
||||
}
|
||||
|
||||
renderProgManager.CommitConstantBuffer( commandList );
|
||||
|
||||
int program = renderProgManager.CurrentProgram();
|
||||
PipelineKey key{ glStateBits, program, depthBias, slopeScaleBias, currentFrameBuffer };
|
||||
auto pipeline = pipelineCache.GetOrCreatePipeline( key );
|
||||
|
||||
|
@ -642,7 +306,7 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
{
|
||||
nvrhi::GraphicsState state;
|
||||
|
||||
for( int i = 0; i < info.bindingLayouts->Num(); i++ )
|
||||
for( int i = 0; i < layouts->Num(); i++ )
|
||||
{
|
||||
state.bindings.push_back( currentBindingSets[i] );
|
||||
}
|
||||
|
@ -671,7 +335,7 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
nvrhi::DrawArguments args;
|
||||
// FIXME idDrawShadowVert
|
||||
args.startVertexLocation = currentVertexOffset / sizeof( idDrawVert );
|
||||
args.startIndexLocation = currentIndexOffset / sizeof( uint16 );
|
||||
args.startIndexLocation = currentIndexOffset / sizeof( triIndex_t );
|
||||
args.vertexCount = surf->numIndexes;
|
||||
commandList->drawIndexed( args );
|
||||
|
||||
|
@ -682,169 +346,340 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
//renderLog.CloseBlock();
|
||||
}
|
||||
|
||||
void idRenderBackend::GetCurrentBindingLayout()
|
||||
void idRenderBackend::GetCurrentBindingLayout( int type )
|
||||
{
|
||||
auto& info = renderProgManager.GetProgramInfo( renderProgManager.CurrentProgram() );
|
||||
auto& desc = pendingBindingSetDescs[type];
|
||||
|
||||
int type = info.bindingLayoutType;
|
||||
if( desc.Num() == 0 )
|
||||
{
|
||||
desc.SetNum( nvrhi::c_MaxBindingLayouts );
|
||||
}
|
||||
|
||||
if( type == BINDING_LAYOUT_DEFAULT )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
|
||||
}
|
||||
|
||||
pendingBindingSetDescs[1].bindings =
|
||||
if( desc[1].bindings.empty() )
|
||||
{
|
||||
//nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_PointWrapSampler )
|
||||
nvrhi::BindingSetItem::Sampler( 0, ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache ) )
|
||||
};
|
||||
desc[1].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache ) )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[1].bindings[0].resourceHandle = ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache );
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_CONSTANT_BUFFER_ONLY )
|
||||
{
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_GBUFFER )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_AMBIENT_LIGHTING_IBL )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 4, ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 7, ( nvrhi::ITexture* )GetImageAt( 7 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 8, ( nvrhi::ITexture* )GetImageAt( 8 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 9, ( nvrhi::ITexture* )GetImageAt( 9 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 10, ( nvrhi::ITexture* )GetImageAt( 10 )->GetTextureID() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 4, ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 7, ( nvrhi::ITexture* )GetImageAt( 7 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 8, ( nvrhi::ITexture* )GetImageAt( 8 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 9, ( nvrhi::ITexture* )GetImageAt( 9 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 10, ( nvrhi::ITexture* )GetImageAt( 10 )->GetTextureID() )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
|
||||
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
|
||||
desc[0].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
|
||||
desc[0].bindings[4].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID();
|
||||
desc[0].bindings[5].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID();
|
||||
desc[0].bindings[6].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 7 )->GetTextureID();
|
||||
desc[0].bindings[7].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 8 )->GetTextureID();
|
||||
desc[0].bindings[8].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 9 )->GetTextureID();
|
||||
desc[0].bindings[9].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 10 )->GetTextureID();
|
||||
}
|
||||
|
||||
pendingBindingSetDescs[1].bindings =
|
||||
if( desc[1].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler )
|
||||
};
|
||||
desc[1].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[1].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler;
|
||||
desc[1].bindings[1].resourceHandle = commonPasses.m_LinearClampSampler;
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_DRAW_AO )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
|
||||
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
|
||||
desc[0].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
|
||||
}
|
||||
|
||||
pendingBindingSetDescs[1].bindings =
|
||||
if( desc[1].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_PointWrapSampler ) // blue noise
|
||||
};
|
||||
desc[1].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_PointWrapSampler ) // blue noise
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[1].bindings[0] = nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_PointWrapSampler );
|
||||
}
|
||||
}
|
||||
/*
|
||||
else if( renderProgManager.BindingLayoutType() == BINDING_LAYOUT_DRAW_AO1 )
|
||||
{
|
||||
bindingSetDesc
|
||||
.addItem( nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ) )
|
||||
.addItem( nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ) )
|
||||
.addItem( nvrhi::BindingSetItem::Sampler( 0, ( nvrhi::ISampler* )GetImageAt( 0 )->GetSampler( samplerCache ) ) );
|
||||
}
|
||||
*/
|
||||
else if( type == BINDING_LAYOUT_DRAW_SHADOW )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ), // blue noise
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_DRAW_INTERACTION )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 4, ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 4, ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID() )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
|
||||
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
|
||||
desc[0].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
|
||||
desc[0].bindings[4].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID();
|
||||
desc[0].bindings[5].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID();
|
||||
}
|
||||
|
||||
pendingBindingSetDescs[1].bindings =
|
||||
if( desc[1].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler )
|
||||
};
|
||||
desc[1].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[1].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler;
|
||||
desc[1].bindings[1].resourceHandle = commonPasses.m_LinearClampSampler;
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_DRAW_INTERACTION_SM )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 4, ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 5, ( nvrhi::ITexture* )GetImageAt( 5 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 6, ( nvrhi::ITexture* )GetImageAt( 6 )->GetTextureID() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 3, ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 4, ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 5, ( nvrhi::ITexture* )GetImageAt( 5 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 6, ( nvrhi::ITexture* )GetImageAt( 6 )->GetTextureID() )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
|
||||
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
|
||||
desc[0].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
|
||||
desc[0].bindings[4].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 3 )->GetTextureID();
|
||||
desc[0].bindings[5].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 4 )->GetTextureID();
|
||||
desc[0].bindings[6].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 5 )->GetTextureID();
|
||||
desc[0].bindings[7].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 6 )->GetTextureID();
|
||||
}
|
||||
|
||||
pendingBindingSetDescs[1].bindings =
|
||||
if( desc[1].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 2, commonPasses.m_LinearClampCompareSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 3, commonPasses.m_PointWrapSampler ) // blue noise
|
||||
};
|
||||
desc[1].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 2, commonPasses.m_LinearClampCompareSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 3, commonPasses.m_PointWrapSampler ) // blue noise
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[1].bindings[0].resourceHandle = commonPasses.m_AnisotropicWrapSampler;
|
||||
desc[1].bindings[1].resourceHandle = commonPasses.m_LinearClampSampler;
|
||||
desc[1].bindings[2].resourceHandle = commonPasses.m_LinearClampCompareSampler;
|
||||
desc[1].bindings[3].resourceHandle = commonPasses.m_PointWrapSampler;
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_DRAW_FOG )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
|
||||
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
|
||||
}
|
||||
|
||||
pendingBindingSetDescs[1].bindings =
|
||||
if( desc[1].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearClampSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler )
|
||||
};
|
||||
desc[1].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearClampSampler ),
|
||||
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[1].bindings[0].resourceHandle = commonPasses.m_LinearClampSampler;
|
||||
desc[1].bindings[1].resourceHandle = commonPasses.m_LinearClampSampler;
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_POST_PROCESS_CNM )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
|
||||
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
|
||||
desc[0].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
|
||||
}
|
||||
|
||||
pendingBindingSetDescs[1].bindings =
|
||||
if( desc[1].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearClampSampler )
|
||||
};
|
||||
desc[1].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearClampSampler )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[1].bindings[0].resourceHandle = commonPasses.m_LinearClampSampler;
|
||||
}
|
||||
}
|
||||
else if( type == BINDING_LAYOUT_NORMAL_CUBE )
|
||||
{
|
||||
pendingBindingSetDescs[0].bindings =
|
||||
if( desc[0].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() )
|
||||
};
|
||||
desc[0].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, renderProgManager.ConstantBuffer() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[0].bindings[0].resourceHandle = renderProgManager.ConstantBuffer();
|
||||
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
|
||||
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
|
||||
}
|
||||
|
||||
pendingBindingSetDescs[1].bindings =
|
||||
if( desc[1].bindings.empty() )
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearWrapSampler )
|
||||
};
|
||||
desc[1].bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearWrapSampler )
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
desc[1].bindings[0].resourceHandle = commonPasses.m_LinearWrapSampler;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -932,7 +767,7 @@ void idRenderBackend::GL_SetDefaultState()
|
|||
RENDERLOG_PRINTF( "--- GL_SetDefaultState ---\n" );
|
||||
|
||||
// make sure our GL state vector is set correctly
|
||||
memset( &glcontext.tmu, 0, sizeof( glcontext.tmu ) );
|
||||
memset( &context.imageParms, 0, sizeof( context.imageParms ) );
|
||||
|
||||
glStateBits = 0;
|
||||
|
||||
|
@ -1226,9 +1061,36 @@ void idRenderBackend::CheckCVars()
|
|||
// RB end
|
||||
}
|
||||
|
||||
void idRenderBackend::BackBufferResizing()
|
||||
/*
|
||||
=============
|
||||
idRenderBackend::ClearCaches
|
||||
|
||||
Clear cached pipeline data when framebuffers get updated or images are reloaded.
|
||||
=============
|
||||
*/
|
||||
void idRenderBackend::ClearCaches()
|
||||
{
|
||||
currentPipeline = nullptr;
|
||||
pipelineCache.Clear();
|
||||
bindingCache.Clear();
|
||||
samplerCache.Clear();
|
||||
|
||||
if( hiZGenPass )
|
||||
{
|
||||
delete hiZGenPass;
|
||||
hiZGenPass = nullptr;
|
||||
}
|
||||
|
||||
if( ssaoPass )
|
||||
{
|
||||
delete ssaoPass;
|
||||
ssaoPass = nullptr;
|
||||
}
|
||||
|
||||
if( toneMapPass )
|
||||
{
|
||||
delete toneMapPass;
|
||||
toneMapPass = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1498,16 +1360,8 @@ idRenderBackend::idRenderBackend
|
|||
*/
|
||||
idRenderBackend::idRenderBackend()
|
||||
{
|
||||
glcontext.frameCounter = 0;
|
||||
glcontext.frameParity = 0;
|
||||
hiZGenPass = nullptr;
|
||||
ssaoPass = nullptr;
|
||||
|
||||
memset( glcontext.tmu, 0, sizeof( glcontext.tmu ) );
|
||||
memset( glcontext.stencilOperations, 0, sizeof( glcontext.stencilOperations ) );
|
||||
|
||||
memset( glcontext.renderLogMainBlockTimeQueryIds, 0, sizeof( glcontext.renderLogMainBlockTimeQueryIds ) );
|
||||
memset( glcontext.renderLogMainBlockTimeQueryIssued, 0, sizeof( glcontext.renderLogMainBlockTimeQueryIssued ) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -120,7 +120,18 @@ void idRenderProgManager::LoadShader( shader_t& shader )
|
|||
|
||||
idStr adjustedName = shader.name;
|
||||
adjustedName.StripFileExtension();
|
||||
adjustedName = idStr( "renderprogs/dxil/" ) + adjustedName + "." + stage + ".bin";
|
||||
if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::D3D12 )
|
||||
{
|
||||
adjustedName = idStr( "renderprogs/dxil/" ) + adjustedName + "." + stage + ".bin";
|
||||
}
|
||||
else if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN )
|
||||
{
|
||||
adjustedName = idStr( "renderprogs/spirv/" ) + adjustedName + "." + stage + ".bin";
|
||||
}
|
||||
else
|
||||
{
|
||||
common->FatalError( "Unsuported graphics api" );
|
||||
}
|
||||
|
||||
ShaderBlob shaderBlob = GetBytecode( adjustedName );
|
||||
|
||||
|
@ -155,6 +166,11 @@ void idRenderProgManager::LoadShader( shader_t& shader )
|
|||
shader.handle = shaderHandle;
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
idRenderProgManager::GetBytecode
|
||||
================================================================================================
|
||||
*/
|
||||
ShaderBlob idRenderProgManager::GetBytecode( const char* fileName )
|
||||
{
|
||||
ShaderBlob blob;
|
||||
|
@ -189,6 +205,11 @@ void idRenderProgManager::LoadProgram( const int programIndex, const int vertexS
|
|||
prog.bindingLayouts = bindingLayouts[prog.bindingLayoutType];
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
idRenderProgManager::LoadComputeProgram
|
||||
================================================================================================
|
||||
*/
|
||||
void idRenderProgManager::LoadComputeProgram( const int programIndex, const int computeShaderIndex )
|
||||
{
|
||||
renderProg_t& prog = renderProgs[programIndex];
|
||||
|
@ -228,6 +249,11 @@ int idRenderProgManager::FindProgram( const char* name, int vIndex, int fIndex,
|
|||
return index;
|
||||
}
|
||||
|
||||
int idRenderProgManager::UniformSize()
|
||||
{
|
||||
return uniforms.Allocated();
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
idRenderProgManager::CommitUnforms
|
||||
|
@ -287,6 +313,5 @@ idRenderProgManager::CommitConstantBuffer
|
|||
*/
|
||||
void idRenderProgManager::CommitConstantBuffer( nvrhi::ICommandList* commandList )
|
||||
{
|
||||
uniforms.Size();
|
||||
commandList->writeBuffer( constantBuffer, &uniforms[0], uniforms.Allocated() );
|
||||
commandList->writeBuffer( constantBuffer, uniforms.Ptr(), uniforms.Allocated() );
|
||||
}
|
|
@ -140,8 +140,12 @@ MipMapGenPass::MipMapGenPass(
|
|||
// BindingLayout
|
||||
nvrhi::BindingLayoutDesc layoutDesc;
|
||||
layoutDesc.visibility = nvrhi::ShaderType::Compute;
|
||||
layoutDesc.bindings.push_back( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) ),
|
||||
layoutDesc.bindings.push_back( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) );
|
||||
layoutDesc.bindings =
|
||||
{
|
||||
nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ),
|
||||
nvrhi::BindingLayoutItem::Texture_SRV( 0 )
|
||||
};
|
||||
|
||||
for( uint mipLevel = 1; mipLevel <= NUM_LODS; ++mipLevel )
|
||||
{
|
||||
layoutDesc.bindings.push_back( nvrhi::BindingLayoutItem::Texture_UAV( mipLevel - 1 ) );
|
||||
|
@ -162,18 +166,21 @@ MipMapGenPass::MipMapGenPass(
|
|||
nvrhi::BindingSetHandle& set = m_BindingSets[i];
|
||||
|
||||
nvrhi::BindingSetDesc setDesc;
|
||||
setDesc.bindings.push_back( nvrhi::BindingSetItem::ConstantBuffer( 0, m_ConstantBuffer ) );
|
||||
setDesc.bindings.push_back( nvrhi::BindingSetItem::Texture_SRV( 0, m_Texture, nvrhi::Format::UNKNOWN, nvrhi::TextureSubresourceSet( i * NUM_LODS, 1, 0, 1 ) ) );
|
||||
setDesc.bindings =
|
||||
{
|
||||
nvrhi::BindingSetItem::ConstantBuffer( 0, m_ConstantBuffer ),
|
||||
nvrhi::BindingSetItem::Texture_SRV( 0, m_Texture, nvrhi::Format::UNKNOWN, nvrhi::TextureSubresourceSet( i * NUM_LODS, 1, 0, 1 ) )
|
||||
};
|
||||
for( uint mipLevel = 1; mipLevel <= NUM_LODS; ++mipLevel )
|
||||
{
|
||||
// output UAVs start after the mip-level UAV that was computed last
|
||||
if( i * NUM_LODS + mipLevel < nmipLevels )
|
||||
{
|
||||
setDesc.bindings.push_back( nvrhi::BindingSetItem::Texture_UAV( mipLevel - 1, m_Texture, nvrhi::Format::UNKNOWN, nvrhi::TextureSubresourceSet( i * NUM_LODS + mipLevel, 1, 0, 1 ) ) );
|
||||
setDesc.addItem( nvrhi::BindingSetItem::Texture_UAV( mipLevel - 1, m_Texture, nvrhi::Format::UNKNOWN, nvrhi::TextureSubresourceSet( i * NUM_LODS + mipLevel, 1, 0, 1 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
setDesc.bindings.push_back( nvrhi::BindingSetItem::Texture_UAV( mipLevel - 1, m_NullTextures->lod[mipLevel - 1] ) );
|
||||
setDesc.addItem( nvrhi::BindingSetItem::Texture_UAV( mipLevel - 1, m_NullTextures->lod[mipLevel - 1] ) );
|
||||
}
|
||||
}
|
||||
set = m_Device->createBindingSet( setDesc, m_BindingLayout );
|
||||
|
|
|
@ -372,12 +372,10 @@ void PipelineCache::GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::Re
|
|||
}
|
||||
}
|
||||
|
||||
// TODO implement Carmack's Reverse with GLS_SEPARATE_STENCIL
|
||||
|
||||
if( stateBits & ( GLS_STENCIL_FUNC_BITS | GLS_STENCIL_FUNC_REF_BITS | GLS_STENCIL_FUNC_MASK_BITS ) )
|
||||
{
|
||||
GLuint ref = GLuint( ( stateBits & GLS_STENCIL_FUNC_REF_BITS ) >> GLS_STENCIL_FUNC_REF_SHIFT );
|
||||
GLuint mask = GLuint( ( stateBits & GLS_STENCIL_FUNC_MASK_BITS ) >> GLS_STENCIL_FUNC_MASK_SHIFT );
|
||||
GLenum func = 0;
|
||||
|
||||
depthStencilState.setStencilRefValue( ( stateBits & GLS_STENCIL_FUNC_REF_BITS ) >> GLS_STENCIL_FUNC_REF_SHIFT );
|
||||
depthStencilState.setStencilReadMask( ( stateBits & GLS_STENCIL_FUNC_MASK_BITS ) >> GLS_STENCIL_FUNC_MASK_SHIFT );
|
||||
depthStencilState.setStencilWriteMask( ( stateBits & GLS_STENCIL_FUNC_MASK_BITS ) >> GLS_STENCIL_FUNC_MASK_SHIFT );
|
||||
|
@ -413,10 +411,6 @@ void PipelineCache::GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::Re
|
|||
|
||||
if( stateBits & ( GLS_STENCIL_OP_FAIL_BITS | GLS_STENCIL_OP_ZFAIL_BITS | GLS_STENCIL_OP_PASS_BITS ) )
|
||||
{
|
||||
GLenum sFail = 0;
|
||||
GLenum zFail = 0;
|
||||
GLenum pass = 0;
|
||||
|
||||
switch( stateBits & GLS_STENCIL_OP_FAIL_BITS )
|
||||
{
|
||||
case GLS_STENCIL_OP_FAIL_KEEP:
|
||||
|
|
|
@ -2625,7 +2625,7 @@ void idRenderBackend::StencilSelectLight( const viewLight_t* vLight )
|
|||
idRenderMatrix::Multiply( viewDef->worldSpace.mvp, vLight->inverseBaseLightProject, invProjectMVPMatrix );
|
||||
RB_SetMVP( invProjectMVPMatrix );
|
||||
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
// two-sided stencil test
|
||||
glStencilOpSeparate( GL_FRONT, GL_KEEP, GL_REPLACE, GL_ZERO );
|
||||
glStencilOpSeparate( GL_BACK, GL_KEEP, GL_ZERO, GL_REPLACE );
|
||||
|
@ -4873,7 +4873,7 @@ void idRenderBackend::CalculateAutomaticExposure()
|
|||
globalFramebuffers.hdr64FBO->Bind();
|
||||
|
||||
// FIXME
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
// read back the contents
|
||||
glReadPixels( 0, 0, 64, 64, GL_RGBA, GL_FLOAT, image );
|
||||
#endif
|
||||
|
@ -5085,7 +5085,7 @@ void idRenderBackend::Bloom( const viewDef_t* _viewDef )
|
|||
//globalFramebuffers.hdrQuarterFBO->Bind();
|
||||
|
||||
// FIXME
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
glClearColor( 0, 0, 0, 1 );
|
||||
// glClear( GL_COLOR_BUFFER_BIT );
|
||||
#endif
|
||||
|
@ -5599,7 +5599,7 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion2( const viewDef_t* _viewDe
|
|||
|
||||
void idRenderBackend::DrawScreenSpaceGlobalIllumination( const viewDef_t* _viewDef )
|
||||
{
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
if( !_viewDef->viewEntitys || _viewDef->is2Dgui )
|
||||
{
|
||||
// 3D views only
|
||||
|
@ -5921,15 +5921,6 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
|
|||
globalImages->LoadDeferredImages( commandList );
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
if( globalImages->hierarchicalZbufferImage->GetTextureID() != textureId || !hiZGenPass )
|
||||
{
|
||||
if( hiZGenPass )
|
||||
{
|
||||
delete hiZGenPass;
|
||||
}
|
||||
hiZGenPass = new MipMapGenPass( deviceManager->GetDevice(), globalImages->hierarchicalZbufferImage->GetTextureHandle() );
|
||||
}
|
||||
|
||||
if( !ssaoPass && r_useNewSsaoPass.GetBool() )
|
||||
{
|
||||
ssaoPass = new SsaoPass(
|
||||
|
@ -5939,10 +5930,21 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
|
|||
globalImages->ambientOcclusionImage[0]->GetTextureHandle() );
|
||||
}
|
||||
|
||||
if( !toneMapPass.IsLoaded() )
|
||||
if( globalImages->hierarchicalZbufferImage->GetTextureID() != textureId || !hiZGenPass )
|
||||
{
|
||||
if( hiZGenPass )
|
||||
{
|
||||
delete hiZGenPass;
|
||||
}
|
||||
hiZGenPass = new MipMapGenPass( deviceManager->GetDevice(), globalImages->hierarchicalZbufferImage->GetTextureHandle() );
|
||||
}
|
||||
|
||||
|
||||
if( !toneMapPass )
|
||||
{
|
||||
TonemapPass::CreateParameters tonemapParms;
|
||||
toneMapPass.Init( deviceManager->GetDevice(), &commonPasses, tonemapParms, globalFramebuffers.ldrFBO->GetApiObject() );
|
||||
toneMapPass = new TonemapPass();
|
||||
toneMapPass->Init( deviceManager->GetDevice(), &commonPasses, tonemapParms, globalFramebuffers.ldrFBO->GetApiObject() );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6307,7 +6309,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
Tonemap( _viewDef );
|
||||
#else
|
||||
ToneMappingParameters parms;
|
||||
toneMapPass.SimpleRender( commandList, parms, viewDef, globalImages->currentRenderHDRImage->GetTextureHandle(), globalFramebuffers.ldrFBO->GetApiObject() );
|
||||
toneMapPass->SimpleRender( commandList, parms, viewDef, globalImages->currentRenderHDRImage->GetTextureHandle(), globalFramebuffers.ldrFBO->GetApiObject() );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -6370,10 +6372,9 @@ void idRenderBackend::MotionBlur()
|
|||
GL_State( GLS_COLORMASK | GLS_DEPTHMASK );
|
||||
|
||||
// FIXME
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
glClearColor( 0, 0, 0, 1 );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
#endif
|
||||
|
||||
GL_Color( 0, 0, 0, 0 );
|
||||
|
@ -6581,16 +6582,12 @@ void idRenderBackend::PostProcess( const void* data )
|
|||
return;
|
||||
}
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
// TODO(Stephen) Skip for NVRHI
|
||||
return;
|
||||
#endif
|
||||
|
||||
renderLog.OpenMainBlock( MRB_POSTPROCESS, commandList );
|
||||
renderLog.OpenBlock( "Render_PostProcessing", colorBlue );
|
||||
|
||||
// FIXME
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
|
||||
// resolve the scaled rendering to a temporary texture
|
||||
postProcessCommand_t* cmd = ( postProcessCommand_t* )data;
|
||||
|
|
|
@ -34,13 +34,16 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "RenderLog.h"
|
||||
|
||||
#include "Passes/CommonPasses.h"
|
||||
#include "Passes/MipMapGenPass.h"
|
||||
#include "Passes/FowardShadingPass.h"
|
||||
#include "Passes/SsaoPass.h"
|
||||
#include "Passes/TonemapPass.h"
|
||||
#if defined(USE_NVRHI)
|
||||
#include "Passes/CommonPasses.h"
|
||||
#include "Passes/MipMapGenPass.h"
|
||||
#include "Passes/FowardShadingPass.h"
|
||||
#include "Passes/SsaoPass.h"
|
||||
#include "Passes/TonemapPass.h"
|
||||
|
||||
#include "PipelineCache.h"
|
||||
#include "PipelineCache.h"
|
||||
|
||||
#endif
|
||||
|
||||
bool GL_CheckErrors_( const char* filename, int line );
|
||||
#if 1 // !defined(RETAIL)
|
||||
|
@ -228,8 +231,7 @@ struct vulkanContext_t
|
|||
|
||||
extern vulkanContext_t vkcontext;
|
||||
|
||||
//#elif !defined( USE_NVRHI )
|
||||
#else
|
||||
#elif !defined( USE_NVRHI )
|
||||
|
||||
struct glContext_t
|
||||
{
|
||||
|
@ -280,7 +282,7 @@ public:
|
|||
void Print();
|
||||
void CheckCVars();
|
||||
|
||||
void BackBufferResizing();
|
||||
void ClearCaches();
|
||||
|
||||
static void ImGui_Init();
|
||||
static void ImGui_Shutdown();
|
||||
|
@ -290,7 +292,7 @@ private:
|
|||
void DrawFlickerBox();
|
||||
|
||||
void DrawElementsWithCounters( const drawSurf_t* surf );
|
||||
void GetCurrentBindingLayout();
|
||||
void GetCurrentBindingLayout( int bindingLayoutType );
|
||||
void DrawStencilShadowPass( const drawSurf_t* drawSurf, const bool renderZPass );
|
||||
|
||||
void SetColorMappings();
|
||||
|
@ -509,22 +511,19 @@ private:
|
|||
uint currentVertexOffset;
|
||||
nvrhi::BufferHandle currentIndexBuffer;
|
||||
uint currentIndexOffset;
|
||||
idStaticList<nvrhi::BindingSetHandle, nvrhi::c_MaxBindingLayouts> currentBindingSets;
|
||||
idStaticList<nvrhi::BindingSetDesc, nvrhi::c_MaxBindingLayouts> pendingBindingSetDescs;
|
||||
nvrhi::BindingLayoutHandle currentBindingLayout;
|
||||
nvrhi::GraphicsPipelineHandle currentPipeline;
|
||||
//nvrhi::RenderState currentRenderState;
|
||||
|
||||
idStaticList<nvrhi::BindingSetHandle, nvrhi::c_MaxBindingLayouts> currentBindingSets;
|
||||
idStaticList<idStaticList<nvrhi::BindingSetDesc, nvrhi::c_MaxBindingLayouts>, NUM_BINDING_LAYOUTS> pendingBindingSetDescs;
|
||||
|
||||
Framebuffer* currentFrameBuffer;
|
||||
Framebuffer* lastFrameBuffer;
|
||||
nvrhi::CommandListHandle commandList;
|
||||
idList<IRenderPass*> renderPasses;
|
||||
CommonRenderPasses commonPasses;
|
||||
SsaoPass* ssaoPass;
|
||||
MipMapGenPass* hiZGenPass;
|
||||
TonemapPass toneMapPass;
|
||||
|
||||
//ForwardShadingPass fowardShadingPass;
|
||||
TonemapPass* toneMapPass;
|
||||
|
||||
BindingCache bindingCache;
|
||||
SamplerCache samplerCache;
|
||||
|
|
|
@ -839,6 +839,7 @@ enum vertexLayoutType_t
|
|||
enum bindingLayoutType_t
|
||||
{
|
||||
BINDING_LAYOUT_DEFAULT,
|
||||
BINDING_LAYOUT_CONSTANT_BUFFER_ONLY,
|
||||
BINDING_LAYOUT_GBUFFER,
|
||||
BINDING_LAYOUT_AMBIENT_LIGHTING_IBL,
|
||||
BINDING_LAYOUT_BLIT,
|
||||
|
|
|
@ -90,7 +90,7 @@ struct pixEvent_t
|
|||
|
||||
idCVar r_pix( "r_pix", "0", CVAR_INTEGER, "print GPU/CPU event timing" );
|
||||
|
||||
#if !defined( USE_VULKAN )
|
||||
#if !defined( USE_VULKAN ) && !defined(USE_NVRHI)
|
||||
static const int MAX_PIX_EVENTS = 256;
|
||||
// defer allocation of this until needed, so we don't waste lots of memory
|
||||
pixEvent_t* pixEvents; // [MAX_PIX_EVENTS]
|
||||
|
@ -141,6 +141,8 @@ void PC_BeginNamedEvent( const char* szName, const idVec4& color )
|
|||
|
||||
qvkCmdDebugMarkerBeginEXT( vkcontext.commandBuffer[ vkcontext.frameParity ], &label );
|
||||
}
|
||||
#elif defined(USE_NVRHI)
|
||||
// SP: TODO
|
||||
#else
|
||||
// RB: colors are not supported in OpenGL
|
||||
|
||||
|
@ -211,6 +213,8 @@ void PC_EndNamedEvent()
|
|||
{
|
||||
qvkCmdDebugMarkerEndEXT( vkcontext.commandBuffer[ vkcontext.frameParity ] );
|
||||
}
|
||||
#elif defined(USE_NVRHI)
|
||||
// SP: nvrhi debugging
|
||||
#else
|
||||
// only do this if RBDOOM-3-BFG was started by RenderDoc or some similar tool
|
||||
if( glConfig.gremedyStringMarkerAvailable && glConfig.khronosDebugAvailable )
|
||||
|
@ -337,6 +341,10 @@ void idRenderLog::OpenMainBlock( renderLogMainBlock_t block, nvrhi::ICommandList
|
|||
uint32 queryIndex = vkcontext.queryAssignedIndex[ vkcontext.frameParity ][ mainBlock * 2 + 0 ] = vkcontext.queryIndex[ vkcontext.frameParity ]++;
|
||||
vkCmdWriteTimestamp( commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, queryPool, queryIndex );
|
||||
|
||||
#elif defined(USE_NVRHI)
|
||||
|
||||
// SP: use nvrhi timer queries
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
// SRS - For OSX use elapsed time query for Apple OpenGL 4.1 using GL_TIME_ELAPSED vs GL_TIMESTAMP (which is not implemented on OSX)
|
||||
// SRS - OSX AMD drivers have a rendering bug (flashing colours) with an elasped time query when Shadow Mapping is on - turn off query for that case unless r_skipAMDWorkarounds is set
|
||||
|
@ -385,6 +393,10 @@ void idRenderLog::CloseMainBlock()
|
|||
uint32 queryIndex = vkcontext.queryAssignedIndex[ vkcontext.frameParity ][ mainBlock * 2 + 1 ] = vkcontext.queryIndex[ vkcontext.frameParity ]++;
|
||||
vkCmdWriteTimestamp( commandBuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, queryPool, queryIndex );
|
||||
|
||||
#elif defined(USE_NVRHI)
|
||||
|
||||
// SP: Close nvrhi timer queries
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
// SRS - For OSX use elapsed time query for Apple OpenGL 4.1 using GL_TIME_ELAPSED vs GL_TIMESTAMP (which is not implemented on OSX)
|
||||
// SRS - OSX AMD drivers have a rendering bug (flashing colours) with an elasped time query when Shadow Mapping is on - turn off query for that case unless r_skipAMDWorkarounds is set
|
||||
|
|
|
@ -181,7 +181,15 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
.addItem( nvrhi::BindingLayoutItem::Sampler( 0 ) );
|
||||
auto samplerOneBindingLayout = device->createBindingLayout( samplerOneLayoutDesc );
|
||||
|
||||
bindingLayouts[BINDING_LAYOUT_DEFAULT] = { device->createBindingLayout( defaultLayoutDesc ), samplerOneBindingLayout };
|
||||
auto defaultLayout = device->createBindingLayout( defaultLayoutDesc );
|
||||
|
||||
bindingLayouts[BINDING_LAYOUT_DEFAULT] = { defaultLayout, samplerOneBindingLayout };
|
||||
|
||||
auto constantBufferLayoutDesc = nvrhi::BindingLayoutDesc()
|
||||
.setVisibility( nvrhi::ShaderType::All )
|
||||
.addItem( nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ) );
|
||||
|
||||
bindingLayouts[BINDING_LAYOUT_CONSTANT_BUFFER_ONLY] = { device->createBindingLayout( constantBufferLayoutDesc ) };
|
||||
|
||||
auto ambientIblLayoutDesc = nvrhi::BindingLayoutDesc()
|
||||
.setVisibility( nvrhi::ShaderType::All )
|
||||
|
@ -407,8 +415,8 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
{ BUILTIN_BUMPY_ENVIRONMENT, "builtin/legacy/bumpyenvironment", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_NORMAL_CUBE },
|
||||
{ BUILTIN_BUMPY_ENVIRONMENT_SKINNED, "builtin/legacy/bumpyenvironment", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_NORMAL_CUBE },
|
||||
|
||||
{ BUILTIN_DEPTH, "builtin/depth", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_DEPTH_SKINNED, "builtin/depth", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_DEPTH, "builtin/depth", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_CONSTANT_BUFFER_ONLY },
|
||||
{ BUILTIN_DEPTH_SKINNED, "builtin/depth", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_CONSTANT_BUFFER_ONLY },
|
||||
|
||||
{ BUILTIN_SHADOW, "builtin/lighting/shadow", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_SHADOW_VERT, BINDING_LAYOUT_DRAW_SHADOW },
|
||||
{ BUILTIN_SHADOW_SKINNED, "builtin/lighting/shadow", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_SHADOW_VERT_SKINNED, BINDING_LAYOUT_DRAW_SHADOW },
|
||||
|
|
|
@ -912,6 +912,7 @@ public:
|
|||
void CachePipeline( uint64 stateBits );
|
||||
int FindProgram( const char* name, int vIndex, int fIndex, bindingLayoutType_t bindingType = BINDING_LAYOUT_DEFAULT );
|
||||
void ZeroUniforms();
|
||||
int UniformSize();
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
void CommitConstantBuffer( nvrhi::ICommandList* commandList );
|
||||
|
@ -928,6 +929,10 @@ public:
|
|||
{
|
||||
return renderProgs[currentIndex].bindingLayoutType;
|
||||
}
|
||||
ID_INLINE idStaticList<nvrhi::BindingLayoutHandle, nvrhi::c_MaxBindingLayouts>* GetBindingLayout( int layoutType )
|
||||
{
|
||||
return &bindingLayouts[layoutType];
|
||||
}
|
||||
#elif defined(USE_VULKAN)
|
||||
void PrintPipelines();
|
||||
void ClearPipelines();
|
||||
|
@ -1038,12 +1043,6 @@ private:
|
|||
|
||||
nvrhi::BufferHandle constantBuffer;
|
||||
|
||||
// Temp
|
||||
nvrhi::InputLayoutHandle inputLayout;
|
||||
nvrhi::BindingLayoutHandle bindingLayout;
|
||||
nvrhi::BindingSetHandle bindingSet;
|
||||
renderProg_t* currentShader;
|
||||
|
||||
#elif defined(USE_VULKAN)
|
||||
struct shader_t
|
||||
{
|
||||
|
|
|
@ -137,7 +137,7 @@ void idRenderSystemLocal::RenderCommandBuffers( const emptyCommand_t* const cmdH
|
|||
if( !r_skipBackEnd.GetBool() )
|
||||
{
|
||||
// SRS - For OSX skip total rendering time query due to missing GL_TIMESTAMP support in Apple OpenGL 4.1, will calculate it inside SwapCommandBuffers_FinishRendering instead
|
||||
#if !defined(USE_VULKAN) && !defined(__APPLE__)
|
||||
#if !defined(USE_VULKAN) && !defined(__APPLE__) && !defined(USE_NVRHI)
|
||||
if( glConfig.timerQueryAvailable )
|
||||
{
|
||||
if( glcontext.renderLogMainBlockTimeQueryIds[ glcontext.frameParity ][ MRB_GPU_TIME ] == 0 )
|
||||
|
@ -945,7 +945,7 @@ const emptyCommand_t* idRenderSystemLocal::SwapCommandBuffers_FinishCommandBuffe
|
|||
setBufferCommand_t* cmd2 = ( setBufferCommand_t* )R_GetCommandBuffer( sizeof( *cmd2 ) );
|
||||
cmd2->commandId = RC_SET_BUFFER;
|
||||
|
||||
#if defined(USE_VULKAN)
|
||||
#if defined(USE_VULKAN) || defined(USE_NVRHI)
|
||||
cmd2->buffer = 0;
|
||||
#else
|
||||
cmd2->buffer = ( int )GL_BACK;
|
||||
|
@ -1213,7 +1213,7 @@ void idRenderSystemLocal::CaptureRenderToFile( const char* fileName, bool fixAlp
|
|||
|
||||
RenderCommandBuffers( frameData->cmdHead );
|
||||
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
glReadBuffer( GL_BACK );
|
||||
|
||||
// include extra space for OpenGL padding to word boundaries
|
||||
|
@ -1297,6 +1297,16 @@ bool idRenderSystemLocal::UploadImage( const char* imageName, const byte* data,
|
|||
{
|
||||
return false;
|
||||
}
|
||||
image->UploadScratch( data, width, height, nullptr );
|
||||
|
||||
#if defined(USE_NVRHI)
|
||||
commandList->open();
|
||||
#endif
|
||||
|
||||
image->UploadScratch( data, width, height, commandList );
|
||||
|
||||
#if defined(USE_NVRHI)
|
||||
commandList->close();
|
||||
deviceManager->GetDevice()->executeCommandList( commandList );
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,9 @@ glconfig_t glConfig;
|
|||
idCVar r_requestStereoPixelFormat( "r_requestStereoPixelFormat", "1", CVAR_RENDERER, "Ask for a stereo GL pixel format on startup" );
|
||||
idCVar r_debugContext( "r_debugContext", "0", CVAR_RENDERER, "Enable various levels of context debug." );
|
||||
idCVar r_glDriver( "r_glDriver", "", CVAR_RENDERER, "\"opengl32\", etc." );
|
||||
#if defined(USE_NVRHI)
|
||||
idCVar r_gapi( "r_gapi", "dx12", CVAR_RENDERER, "Specifies the graphics api to use (dx12, vulkan)" );
|
||||
#endif
|
||||
// SRS - Added workaround for AMD OSX driver bugs caused by GL_EXT_timer_query when shadow mapping enabled; Intel bugs not present on OSX
|
||||
#if defined(__APPLE__)
|
||||
idCVar r_skipIntelWorkarounds( "r_skipIntelWorkarounds", "1", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for Intel driver bugs" );
|
||||
|
@ -456,7 +459,16 @@ void R_SetNewMode( const bool fullInit )
|
|||
// create the context as well as setting up the window
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
deviceManager = DeviceManager::Create( nvrhi::GraphicsAPI::D3D12 );
|
||||
nvrhi::GraphicsAPI api = nvrhi::GraphicsAPI::D3D12;
|
||||
if( !idStr::Icmp( r_gapi.GetString(), "vulkan" ) )
|
||||
{
|
||||
api = nvrhi::GraphicsAPI::VULKAN;
|
||||
}
|
||||
else if( !idStr::Icmp( r_gapi.GetString(), "dx12" ) )
|
||||
{
|
||||
api = nvrhi::GraphicsAPI::D3D12;
|
||||
}
|
||||
deviceManager = DeviceManager::Create( api );
|
||||
#endif
|
||||
|
||||
#if defined( USE_VULKAN )
|
||||
|
@ -768,7 +780,7 @@ If ref isn't specified, the full session UpdateScreen will be done.
|
|||
void R_ReadTiledPixels( int width, int height, byte* buffer, renderView_t* ref = NULL )
|
||||
{
|
||||
// FIXME
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
|
||||
// include extra space for OpenGL padding to word boundaries
|
||||
int sysWidth = renderSystem->GetWidth();
|
||||
|
@ -1523,7 +1535,7 @@ void GfxInfo_f( const idCmdArgs& args )
|
|||
common->Printf( "-------\n" );
|
||||
|
||||
// RB begin
|
||||
#if defined(_WIN32) && !defined(USE_VULKAN)
|
||||
#if defined(_WIN32) && !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
// WGL_EXT_swap_interval
|
||||
if( r_swapInterval.GetInteger() && wglSwapIntervalEXT != NULL )
|
||||
{
|
||||
|
|
|
@ -1064,6 +1064,10 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
|
|||
|
||||
// TODO
|
||||
|
||||
#elif defined(USE_NVRHI)
|
||||
|
||||
// TODO
|
||||
|
||||
#else
|
||||
|
||||
glFinish();
|
||||
|
|
|
@ -1294,6 +1294,8 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
#if defined(USE_VULKAN)
|
||||
|
||||
// TODO
|
||||
#elif defined(USE_NVRHI)
|
||||
// TODO
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#pragma hdrstop
|
||||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "../RenderCommon.h"
|
||||
|
||||
|
@ -70,7 +70,6 @@ stenciling will matter.
|
|||
*/
|
||||
void idRenderBackend::DBG_PolygonClear()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -92,7 +91,6 @@ Debugging tool to see what values are in the stencil buffer
|
|||
*/
|
||||
void idRenderBackend::DBG_ScanStencilBuffer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,7 +103,6 @@ Print an overdraw count based on stencil index values
|
|||
*/
|
||||
void idRenderBackend::DBG_CountStencilBuffer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -119,7 +116,6 @@ stencil buffer. Stencil of 0 = black, 1 = red, 2 = green,
|
|||
*/
|
||||
void idRenderBackend::DBG_ColorByStencilBuffer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -255,7 +251,6 @@ green if they have a negative texture area, or blue if degenerate area
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowTexturePolarity( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -267,7 +262,6 @@ Shade materials that are using unsmoothed tangents
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowUnsmoothedTangents( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -282,7 +276,6 @@ Shade a triangle by the RGB colors of its tangent space
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowTangentSpace( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -294,7 +287,6 @@ Draw each triangle with the solid vertex colors
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowVertexColor( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -306,7 +298,6 @@ Debugging tool
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowNormals( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -318,7 +309,6 @@ Draw texture vectors in the center of each triangle
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowTextureVectors( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -330,7 +320,6 @@ Draw lines from each vertex to the dominant triangle center
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowDominantTris( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -342,7 +331,6 @@ Debugging tool
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowEdges( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -376,7 +364,6 @@ Debugging tool, won't work correctly with SMP or when mirrors are present
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowPortals()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -501,7 +488,6 @@ idRenderBackend::DBG_ShowCenterOfProjection
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowCenterOfProjection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -513,7 +499,6 @@ Draw exact pixel lines to check pixel center sampling
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowLines()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -524,7 +509,6 @@ idRenderBackend::DBG_TestGamma
|
|||
*/
|
||||
void idRenderBackend::DBG_TestGamma()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -535,7 +519,6 @@ idRenderBackend::DBG_TestGammaBias
|
|||
*/
|
||||
void idRenderBackend::DBG_TestGammaBias()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -674,7 +657,6 @@ RB_DrawExpandedTriangles
|
|||
*/
|
||||
static void RB_DrawExpandedTriangles( const srfTriangles_t* tri, const float radius, const idVec3& vieworg )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -688,7 +670,6 @@ FIXME: not thread safe!
|
|||
*/
|
||||
void idRenderBackend::DBG_ShowTrace( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -698,6 +679,11 @@ idRenderBackend::DBG_RenderDebugTools
|
|||
*/
|
||||
void idRenderBackend::DBG_RenderDebugTools( drawSurf_t** drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
if( viewDef->renderView.rdflags & RDF_IRRADIANCE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// don't do much if this was a 2D rendering
|
||||
if( !viewDef->viewEntitys )
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
include(../compileshaders.cmake)
|
||||
|
||||
file(GLOB globalshaders "BRDF.inc.hlsl" "global_inc.hlsl")
|
||||
file(GLOB globalshaders "BRDF.inc.hlsl" "global_inc.hlsl" "vulkan.hlsli")
|
||||
file(GLOB builtins "builtin/*.hlsl")
|
||||
file(GLOB debug "builtin/debug/*hlsl")
|
||||
file(GLOB fog "builtin/fog/*hlsl")
|
||||
|
|
|
@ -93,11 +93,11 @@ static const float projScale = 500.0;
|
|||
|
||||
#define VALUE_TYPE float
|
||||
|
||||
Texture2D t_NormalRoughness : register( t0 );
|
||||
Texture2D<VALUE_TYPE> t_ViewDepth : register( t1 );
|
||||
Texture2D t_BlueNoise : register( t2 );
|
||||
Texture2D t_NormalRoughness : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D<VALUE_TYPE> t_ViewDepth : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BlueNoise : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState blueNoiseSampler : register( s0 );
|
||||
SamplerState blueNoiseSampler : register( s0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
|
||||
#define CS_Z_buffer t_ViewDepth
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
// *INDENT-OFF*
|
||||
#define VALUE_TYPE float
|
||||
|
||||
Texture2D t_NormalRoughness : register( t0 );
|
||||
Texture2D<VALUE_TYPE> t_ViewDepth : register( t1 );
|
||||
Texture2D t_Ao : register( t2 );
|
||||
Texture2D t_NormalRoughness : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D<VALUE_TYPE> t_ViewDepth : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Ao : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
#define normal_buffer t_NormalRoughness
|
||||
#define cszBuffer t_ViewDepth
|
||||
|
|
|
@ -31,10 +31,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Light1 : register( t0 );
|
||||
Texture2D t_Light2 : register( t1 );
|
||||
SamplerState samp0 : register( s0 );
|
||||
SamplerState samp1 : register( s1 );
|
||||
Texture2D t_Light1 : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Light2 : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
SamplerState samp0 : register( s0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
SamplerState samp1 : register( s1 VK_DESCRIPTOR_SET( 1 ) );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : SV_Position;
|
||||
|
|
|
@ -31,11 +31,11 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Fog1 : register( t0 );
|
||||
Texture2D t_Fog2 : register( t1 );
|
||||
Texture2D t_Fog1 : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Fog2 : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState samp0 : register(s0);
|
||||
SamplerState samp1 : register(s1);
|
||||
SamplerState samp0 : register(s0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
SamplerState samp1 : register(s1 VK_DESCRIPTOR_SET( 1 ) );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : SV_Position;
|
||||
|
|
|
@ -31,22 +31,21 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "BRDF.inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Normal : register( t0 );
|
||||
Texture2D t_Specular : register( t1 );
|
||||
Texture2D t_BaseColor : register( t2 );
|
||||
Texture2D t_BrdfLut : register( t3 );
|
||||
Texture2D t_Ssao : register( t4 );
|
||||
Texture2D t_Normal : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Specular : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BaseColor : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BrdfLut : register( t3 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Ssao : register( t4 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
Texture2D t_IrradianceCubeMap : register( t7 );
|
||||
Texture2D t_RadianceCubeMap1 : register( t8 );
|
||||
Texture2D t_RadianceCubeMap2 : register( t9 );
|
||||
Texture2D t_RadianceCubeMap3 : register( t10 );
|
||||
Texture2D t_IrradianceCubeMap : register( t7 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_RadianceCubeMap1 : register( t8 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_RadianceCubeMap2 : register( t9 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_RadianceCubeMap3 : register( t10 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState s_Material : register( s0 ); // (Wrap) Anisotropic sampler: normal sampler & specular sampler
|
||||
SamplerState s_LinearClamp : register( s1 ); // (Clamp) Linear sampler: brdf lut sampler & ssao sampler
|
||||
//SamplerState s_Light : register( s2 ); // (Clamp) Anisotropic sampler: irradiance, radiance 1, 2 and 3.
|
||||
SamplerState s_Material : register( s0 VK_DESCRIPTOR_SET( 1 ) ); // (Wrap) Anisotropic sampler: normal sampler & specular sampler
|
||||
SamplerState s_LinearClamp : register( s1 VK_DESCRIPTOR_SET( 1 ) ); // (Clamp) Linear sampler: brdf lut sampler & ssao sampler
|
||||
//SamplerState s_Light : register( s2 VK_DESCRIPTOR_SET( 1 )); // (Clamp) Anisotropic sampler: irradiance, radiance 1, 2 and 3.
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
|
|
@ -33,20 +33,20 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Normal : register( t0 );
|
||||
Texture2D t_Specular : register( t1 );
|
||||
Texture2D t_BaseColor : register( t2 );
|
||||
Texture2D t_BrdfLut : register( t3 );
|
||||
Texture2D t_Ssao : register( t4 );
|
||||
Texture2D t_Normal : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Specular : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BaseColor : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BrdfLut : register( t3 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Ssao : register( t4 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
Texture2D t_IrradianceCubeMap : register( t7 );
|
||||
Texture2D t_RadianceCubeMap1 : register( t8 );
|
||||
Texture2D t_RadianceCubeMap2 : register( t9 );
|
||||
Texture2D t_RadianceCubeMap3 : register( t10 );
|
||||
Texture2D t_IrradianceCubeMap : register( t7 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_RadianceCubeMap1 : register( t8 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_RadianceCubeMap2 : register( t9 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_RadianceCubeMap3 : register( t10 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState s_Material : register( s0 ); // (Wrap) Anisotropic sampler: normal sampler & specular sampler
|
||||
SamplerState s_LinearClamp : register( s1 ); // (Clamp) Linear sampler: brdf lut sampler & ssao sampler
|
||||
//SamplerState s_Light : register( s2 ); // (Clamp) Anisotropic sampler: irradiance, radiance 1, 2 and 3.
|
||||
SamplerState s_Material : register( s0 VK_DESCRIPTOR_SET( 1 ) ); // (Wrap) Anisotropic sampler: normal sampler & specular sampler
|
||||
SamplerState s_LinearClamp : register( s1 VK_DESCRIPTOR_SET( 1 ) ); // (Clamp) Linear sampler: brdf lut sampler & ssao sampler
|
||||
//SamplerState s_Light : register( s2 VK_DESCRIPTOR_SET( 1 )); // (Clamp) Anisotropic sampler: irradiance, radiance 1, 2 and 3.
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
|
|
@ -32,26 +32,26 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Normal : register( t0 );
|
||||
Texture2D t_Specular : register( t1 );
|
||||
Texture2D t_BaseColor : register( t2 );
|
||||
Texture2D t_LightFalloff : register( t3 );
|
||||
Texture2D t_LightProjection : register( t4 );
|
||||
Texture2D t_Normal : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Specular : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BaseColor : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_LightFalloff : register( t3 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_LightProjection : register( t4 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState s_Material : register( s0 ); // for the normal/specular/basecolor
|
||||
SamplerState s_Lighting : register( s1 ); // for sampling the jitter
|
||||
SamplerState s_Material : register( s0 VK_DESCRIPTOR_SET( 1 ) ); // for the normal/specular/basecolor
|
||||
SamplerState s_Lighting : register( s1 VK_DESCRIPTOR_SET( 1 ) ); // for sampling the jitter
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
half4 position : SV_Position;
|
||||
half4 texcoord0 : TEXCOORD0_centroid;
|
||||
half4 texcoord1 : TEXCOORD1_centroid;
|
||||
half4 texcoord2 : TEXCOORD2_centroid;
|
||||
half4 texcoord3 : TEXCOORD3_centroid;
|
||||
half4 texcoord4 : TEXCOORD4_centroid;
|
||||
half4 texcoord5 : TEXCOORD5_centroid;
|
||||
half4 texcoord6 : TEXCOORD6_centroid;
|
||||
half4 color : COLOR0;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
float4 texcoord3 : TEXCOORD3_centroid;
|
||||
float4 texcoord4 : TEXCOORD4_centroid;
|
||||
float4 texcoord5 : TEXCOORD5_centroid;
|
||||
float4 texcoord6 : TEXCOORD6_centroid;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
struct PS_OUT
|
||||
|
@ -62,18 +62,18 @@ struct PS_OUT
|
|||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
half4 bumpMap = t_Normal.Sample( s_Material, fragment.texcoord1.xy );
|
||||
half4 lightFalloff = idtex2Dproj( s_Lighting, t_LightFalloff, fragment.texcoord2 );
|
||||
half4 lightProj = idtex2Dproj( s_Lighting, t_LightProjection, fragment.texcoord3 );
|
||||
half4 YCoCG = t_BaseColor.Sample( s_Material, fragment.texcoord4.xy );
|
||||
half4 specMapSRGB = t_Specular.Sample( s_Material, fragment.texcoord5.xy );
|
||||
half4 specMap = sRGBAToLinearRGBA( specMapSRGB );
|
||||
float4 bumpMap = t_Normal.Sample( s_Material, fragment.texcoord1.xy );
|
||||
float4 lightFalloff = idtex2Dproj( s_Lighting, t_LightFalloff, fragment.texcoord2 );
|
||||
float4 lightProj = idtex2Dproj( s_Lighting, t_LightProjection, fragment.texcoord3 );
|
||||
float4 YCoCG = t_BaseColor.Sample( s_Material, fragment.texcoord4.xy );
|
||||
float4 specMapSRGB = t_Specular.Sample( s_Material, fragment.texcoord5.xy );
|
||||
float4 specMap = sRGBAToLinearRGBA( specMapSRGB );
|
||||
|
||||
half3 lightVector = normalize( fragment.texcoord0.xyz );
|
||||
half3 viewVector = normalize( fragment.texcoord6.xyz );
|
||||
half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );
|
||||
float3 lightVector = normalize( fragment.texcoord0.xyz );
|
||||
float3 viewVector = normalize( fragment.texcoord6.xyz );
|
||||
float3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );
|
||||
|
||||
half3 localNormal;
|
||||
float3 localNormal;
|
||||
// RB begin
|
||||
#if defined(USE_NORMAL_FMT_RGB8)
|
||||
localNormal.xy = bumpMap.rg - 0.5;
|
||||
|
@ -85,44 +85,44 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
localNormal = normalize( localNormal );
|
||||
|
||||
// traditional very dark Lambert light model used in Doom 3
|
||||
half ldotN = saturate( dot3( localNormal, lightVector ) );
|
||||
float ldotN = saturate( dot3( localNormal, lightVector ) );
|
||||
|
||||
#if defined(USE_HALF_LAMBERT)
|
||||
// RB: http://developer.valvesoftware.com/wiki/Half_Lambert
|
||||
half halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
|
||||
float halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
|
||||
halfLdotN *= halfLdotN;
|
||||
|
||||
// tweak to not loose so many details
|
||||
half lambert = lerp( ldotN, halfLdotN, 0.5 );
|
||||
float lambert = lerp( ldotN, halfLdotN, 0.5 );
|
||||
#else
|
||||
half lambert = ldotN;
|
||||
float lambert = ldotN;
|
||||
#endif
|
||||
|
||||
|
||||
half3 halfAngleVector = normalize( lightVector + viewVector );
|
||||
half hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 );
|
||||
float3 halfAngleVector = normalize( lightVector + viewVector );
|
||||
float hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 );
|
||||
|
||||
#if USE_PBR
|
||||
const half metallic = specMapSRGB.g;
|
||||
const half roughness = specMapSRGB.r;
|
||||
const half glossiness = 1.0 - roughness;
|
||||
const float metallic = specMapSRGB.g;
|
||||
const float roughness = specMapSRGB.r;
|
||||
const float glossiness = 1.0 - roughness;
|
||||
|
||||
// the vast majority of real-world materials (anything not metal or gems) have F(0<>)
|
||||
// values in a very narrow range (~0.02 - 0.08)
|
||||
|
||||
// approximate non-metals with linear RGB 0.04 which is 0.08 * 0.5 (default in UE4)
|
||||
const half3 dielectricColor = _half3( 0.04 );
|
||||
const float3 dielectricColor = _float3( 0.04 );
|
||||
|
||||
// derive diffuse and specular from albedo(m) base color
|
||||
const half3 baseColor = diffuseMap;
|
||||
const float3 baseColor = diffuseMap;
|
||||
|
||||
half3 diffuseColor = baseColor * ( 1.0 - metallic );
|
||||
half3 specularColor = lerp( dielectricColor, baseColor, metallic );
|
||||
float3 diffuseColor = baseColor * ( 1.0 - metallic );
|
||||
float3 specularColor = lerp( dielectricColor, baseColor, metallic );
|
||||
#else
|
||||
const float roughness = EstimateLegacyRoughness( specMapSRGB.rgb );
|
||||
|
||||
half3 diffuseColor = diffuseMap;
|
||||
half3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat
|
||||
float3 diffuseColor = diffuseMap;
|
||||
float3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -130,14 +130,14 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
//lambert *= 1.3;
|
||||
|
||||
// rpDiffuseModifier contains light color multiplier
|
||||
half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );
|
||||
float3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );
|
||||
|
||||
half vdotN = clamp( dot3( viewVector, localNormal ), 0.0, 1.0 );
|
||||
half vdotH = clamp( dot3( viewVector, halfAngleVector ), 0.0, 1.0 );
|
||||
half ldotH = clamp( dot3( lightVector, halfAngleVector ), 0.0, 1.0 );
|
||||
float vdotN = clamp( dot3( viewVector, localNormal ), 0.0, 1.0 );
|
||||
float vdotH = clamp( dot3( viewVector, halfAngleVector ), 0.0, 1.0 );
|
||||
float ldotH = clamp( dot3( lightVector, halfAngleVector ), 0.0, 1.0 );
|
||||
|
||||
// compensate r_lightScale 3 * 2
|
||||
half3 reflectColor = specularColor * rpSpecularModifier.rgb * 1.0;// * 0.5;
|
||||
float3 reflectColor = specularColor * rpSpecularModifier.rgb * 1.0;// * 0.5;
|
||||
|
||||
// cheap approximation by ARM with only one division
|
||||
// http://community.arm.com/servlet/JiveServlet/download/96891546-19496/siggraph2015-mmg-renaldas-slides.pdf
|
||||
|
@ -149,19 +149,19 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
// disney GGX
|
||||
float D = ( hdotN * hdotN ) * ( rrrr - 1.0 ) + 1.0;
|
||||
float VFapprox = ( ldotH * ldotH ) * ( roughness + 0.5 );
|
||||
half3 specularLight = ( rrrr / ( 4.0 * PI * D * D * VFapprox ) ) * ldotN * reflectColor;
|
||||
//specularLight = half3( 0.0 );
|
||||
float3 specularLight = ( rrrr / ( 4.0 * PI * D * D * VFapprox ) ) * ldotN * reflectColor;
|
||||
//specularLight = float3( 0.0 );
|
||||
|
||||
#if 0
|
||||
result.color = float4( _half3( VFapprox ), 1.0 );
|
||||
result.color = float4( _float3( VFapprox ), 1.0 );
|
||||
return;
|
||||
#endif
|
||||
|
||||
// see http://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/
|
||||
//lambert /= PI;
|
||||
|
||||
//half3 diffuseColor = mix( diffuseMap, F0, metal ) * rpDiffuseModifier.xyz;
|
||||
half3 diffuseLight = diffuseColor * lambert * ( rpDiffuseModifier.xyz );
|
||||
//float3 diffuseColor = mix( diffuseMap, F0, metal ) * rpDiffuseModifier.xyz;
|
||||
float3 diffuseLight = diffuseColor * lambert * ( rpDiffuseModifier.xyz );
|
||||
|
||||
float3 color = ( diffuseLight + specularLight ) * lightColor * fragment.color.rgb;
|
||||
|
||||
|
|
|
@ -31,17 +31,17 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Normal : register( t0 );
|
||||
Texture2D t_Specular : register( t1 );
|
||||
Texture2D t_BaseColor : register( t2 );
|
||||
Texture2D t_LightFalloff : register( t3 );
|
||||
Texture2D t_LightProjection : register( t4 );
|
||||
Texture2D t_Normal : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Specular : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BaseColor : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_LightFalloff : register( t3 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_LightProjection : register( t4 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState samp0 : register(s0); // texture 1 is the per-surface normal map
|
||||
SamplerState samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map
|
||||
SamplerState samp2 : register(s2); // texture 2 is the per-surface baseColor map
|
||||
SamplerState samp3 : register(s3); // texture 4 is the light falloff texture
|
||||
SamplerState samp4 : register(s4); // texture 5 is the light projection texture
|
||||
SamplerState samp0 : register( s0 VK_DESCRIPTOR_SET( 1 ) ); // texture 1 is the per-surface normal map
|
||||
SamplerState samp1 : register( s1 VK_DESCRIPTOR_SET( 1 ) ); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map
|
||||
SamplerState samp2 : register( s2 VK_DESCRIPTOR_SET( 1 ) ); // texture 2 is the per-surface baseColor map
|
||||
SamplerState samp3 : register( s3 VK_DESCRIPTOR_SET( 1 ) ); // texture 4 is the light falloff texture
|
||||
SamplerState samp4 : register( s4 VK_DESCRIPTOR_SET( 1 ) ); // texture 5 is the light projection texture
|
||||
|
||||
struct PS_IN {
|
||||
half4 position : SV_Position;
|
||||
|
|
|
@ -33,38 +33,38 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Normal : register( t0 );
|
||||
Texture2D t_Specular : register( t1 );
|
||||
Texture2D t_BaseColor : register( t2 );
|
||||
Texture2D t_LightFalloff : register( t3 );
|
||||
Texture2D t_LightProjection : register( t4 );
|
||||
Texture2DArray<float> t_ShadowMapArray : register( t5 );
|
||||
Texture2D t_Jitter : register( t6 );
|
||||
Texture2D t_Normal : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Specular : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BaseColor : register( t2 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_LightFalloff : register( t3 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_LightProjection : register( t4 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2DArray<float> t_ShadowMapArray : register( t5 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_Jitter : register( t6 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState s_Material : register( s0 ); // for the normal/specular/basecolor
|
||||
SamplerState s_Lighting : register( s1 ); // for sampling the jitter
|
||||
SamplerComparisonState s_Shadow : register( s2 ); // for the depth shadow map sampler with a compare function
|
||||
SamplerState s_Jitter : register( s3 ); // for sampling the jitter
|
||||
SamplerState s_Material : register( s0 VK_DESCRIPTOR_SET( 1 ) ); // for the normal/specular/basecolor
|
||||
SamplerState s_Lighting : register( s1 VK_DESCRIPTOR_SET( 1 ) ); // for sampling the jitter
|
||||
SamplerComparisonState s_Shadow : register( s2 VK_DESCRIPTOR_SET( 1 ) ); // for the depth shadow map sampler with a compare function
|
||||
SamplerState s_Jitter : register( s3 VK_DESCRIPTOR_SET( 1 ) ); // for sampling the jitter
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
half4 position : SV_Position;
|
||||
half4 texcoord0 : TEXCOORD0_centroid;
|
||||
half4 texcoord1 : TEXCOORD1_centroid;
|
||||
half4 texcoord2 : TEXCOORD2_centroid;
|
||||
half4 texcoord3 : TEXCOORD3_centroid;
|
||||
half4 texcoord4 : TEXCOORD4_centroid;
|
||||
half4 texcoord5 : TEXCOORD5_centroid;
|
||||
half4 texcoord6 : TEXCOORD6_centroid;
|
||||
half4 texcoord7 : TEXCOORD7_centroid;
|
||||
half4 texcoord8 : TEXCOORD8_centroid;
|
||||
half4 texcoord9 : TEXCOORD9_centroid;
|
||||
half4 color : COLOR0;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
float4 texcoord3 : TEXCOORD3_centroid;
|
||||
float4 texcoord4 : TEXCOORD4_centroid;
|
||||
float4 texcoord5 : TEXCOORD5_centroid;
|
||||
float4 texcoord6 : TEXCOORD6_centroid;
|
||||
float4 texcoord7 : TEXCOORD7_centroid;
|
||||
float4 texcoord8 : TEXCOORD8_centroid;
|
||||
float4 texcoord9 : TEXCOORD9_centroid;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
struct PS_OUT
|
||||
{
|
||||
half4 color : SV_Target0;
|
||||
float4 color : SV_Target0;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -97,18 +97,18 @@ float2 VogelDiskSample( float sampleIndex, float samplesCount, float phi )
|
|||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
half4 bumpMap = t_Normal.Sample( s_Material, fragment.texcoord1.xy );
|
||||
half4 lightFalloff = idtex2Dproj( s_Lighting, t_LightFalloff, fragment.texcoord2 );
|
||||
half4 lightProj = idtex2Dproj( s_Lighting, t_LightProjection, fragment.texcoord3 );
|
||||
half4 YCoCG = t_BaseColor.Sample( s_Material, fragment.texcoord4.xy );
|
||||
half4 specMapSRGB = t_Specular.Sample( s_Material, fragment.texcoord5.xy );
|
||||
half4 specMap = sRGBAToLinearRGBA( specMapSRGB );
|
||||
float4 bumpMap = t_Normal.Sample( s_Material, fragment.texcoord1.xy );
|
||||
float4 lightFalloff = idtex2Dproj( s_Lighting, t_LightFalloff, fragment.texcoord2 );
|
||||
float4 lightProj = idtex2Dproj( s_Lighting, t_LightProjection, fragment.texcoord3 );
|
||||
float4 YCoCG = t_BaseColor.Sample( s_Material, fragment.texcoord4.xy );
|
||||
float4 specMapSRGB = t_Specular.Sample( s_Material, fragment.texcoord5.xy );
|
||||
float4 specMap = sRGBAToLinearRGBA( specMapSRGB );
|
||||
|
||||
half3 lightVector = normalize( fragment.texcoord0.xyz );
|
||||
half3 viewVector = normalize( fragment.texcoord6.xyz );
|
||||
half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );
|
||||
float3 lightVector = normalize( fragment.texcoord0.xyz );
|
||||
float3 viewVector = normalize( fragment.texcoord6.xyz );
|
||||
float3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );
|
||||
|
||||
half3 localNormal;
|
||||
float3 localNormal;
|
||||
// RB begin
|
||||
#if USE_NORMAL_FMT_RGB8
|
||||
localNormal.xy = bumpMap.rg - 0.5;
|
||||
|
@ -120,17 +120,17 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
localNormal = normalize( localNormal );
|
||||
|
||||
// traditional very dark Lambert light model used in Doom 3
|
||||
half ldotN = saturate( dot3( localNormal, lightVector ) );
|
||||
float ldotN = saturate( dot3( localNormal, lightVector ) );
|
||||
|
||||
#if defined(USE_HALF_LAMBERT)
|
||||
// RB: http://developer.valvesoftware.com/wiki/Half_Lambert
|
||||
half halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
|
||||
float halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
|
||||
halfLdotN *= halfLdotN;
|
||||
|
||||
// tweak to not loose so many details
|
||||
half lambert = lerp( ldotN, halfLdotN, 0.5 );
|
||||
float lambert = lerp( ldotN, halfLdotN, 0.5 );
|
||||
#else
|
||||
half lambert = ldotN;
|
||||
float lambert = ldotN;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -431,30 +431,30 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
#endif
|
||||
|
||||
half3 halfAngleVector = normalize( lightVector + viewVector );
|
||||
half hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 );
|
||||
float3 halfAngleVector = normalize( lightVector + viewVector );
|
||||
float hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 );
|
||||
|
||||
#if USE_PBR
|
||||
const half metallic = specMapSRGB.g;
|
||||
const half roughness = specMapSRGB.r;
|
||||
const half glossiness = 1.0 - roughness;
|
||||
const float metallic = specMapSRGB.g;
|
||||
const float roughness = specMapSRGB.r;
|
||||
const float glossiness = 1.0 - roughness;
|
||||
|
||||
// the vast majority of real-world materials (anything not metal or gems) have F(0<>)
|
||||
// values in a very narrow range (~0.02 - 0.08)
|
||||
|
||||
// approximate non-metals with linear RGB 0.04 which is 0.08 * 0.5 (default in UE4)
|
||||
const half3 dielectricColor = _half3( 0.04 );
|
||||
const float3 dielectricColor = _float3( 0.04 );
|
||||
|
||||
// derive diffuse and specular from albedo(m) base color
|
||||
const half3 baseColor = diffuseMap;
|
||||
const float3 baseColor = diffuseMap;
|
||||
|
||||
half3 diffuseColor = baseColor * ( 1.0 - metallic );
|
||||
half3 specularColor = lerp( dielectricColor, baseColor, metallic );
|
||||
float3 diffuseColor = baseColor * ( 1.0 - metallic );
|
||||
float3 specularColor = lerp( dielectricColor, baseColor, metallic );
|
||||
#else
|
||||
const float roughness = EstimateLegacyRoughness( specMapSRGB.rgb );
|
||||
|
||||
half3 diffuseColor = diffuseMap;
|
||||
half3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat
|
||||
float3 diffuseColor = diffuseMap;
|
||||
float3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -462,14 +462,14 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
//lambert *= 1.3;
|
||||
|
||||
// rpDiffuseModifier contains light color multiplier
|
||||
half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );
|
||||
float3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );
|
||||
|
||||
half vdotN = clamp( dot3( viewVector, localNormal ), 0.0, 1.0 );
|
||||
half vdotH = clamp( dot3( viewVector, halfAngleVector ), 0.0, 1.0 );
|
||||
half ldotH = clamp( dot3( lightVector, halfAngleVector ), 0.0, 1.0 );
|
||||
float vdotN = clamp( dot3( viewVector, localNormal ), 0.0, 1.0 );
|
||||
float vdotH = clamp( dot3( viewVector, halfAngleVector ), 0.0, 1.0 );
|
||||
float ldotH = clamp( dot3( lightVector, halfAngleVector ), 0.0, 1.0 );
|
||||
|
||||
// compensate r_lightScale 3 * 2
|
||||
half3 reflectColor = specularColor * rpSpecularModifier.rgb * 1.0;// * 0.5;
|
||||
float3 reflectColor = specularColor * rpSpecularModifier.rgb * 1.0;// * 0.5;
|
||||
|
||||
// cheap approximation by ARM with only one division
|
||||
// http://community.arm.com/servlet/JiveServlet/download/96891546-19496/siggraph2015-mmg-renaldas-slides.pdf
|
||||
|
@ -481,19 +481,19 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
// disney GGX
|
||||
float D = ( hdotN * hdotN ) * ( rrrr - 1.0 ) + 1.0;
|
||||
float VFapprox = ( ldotH * ldotH ) * ( roughness + 0.5 );
|
||||
half3 specularLight = ( rrrr / ( 4.0 * PI * D * D * VFapprox ) ) * ldotN * reflectColor;
|
||||
//specularLight = half3( 0.0 );
|
||||
float3 specularLight = ( rrrr / ( 4.0 * PI * D * D * VFapprox ) ) * ldotN * reflectColor;
|
||||
//specularLight = float3( 0.0 );
|
||||
|
||||
#if 0
|
||||
result.color = float4( _half3( VFapprox ), 1.0 );
|
||||
result.color = float4( _float3( VFapprox ), 1.0 );
|
||||
return;
|
||||
#endif
|
||||
|
||||
// see http://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/
|
||||
//lambert /= PI;
|
||||
|
||||
//half3 diffuseColor = mix( diffuseMap, F0, metal ) * rpDiffuseModifier.xyz;
|
||||
half3 diffuseLight = diffuseColor * lambert * ( rpDiffuseModifier.xyz );
|
||||
//float3 diffuseColor = mix( diffuseMap, F0, metal ) * rpDiffuseModifier.xyz;
|
||||
float3 diffuseLight = diffuseColor * lambert * ( rpDiffuseModifier.xyz );
|
||||
|
||||
float3 color = ( diffuseLight + specularLight ) * lightColor * fragment.color.rgb * shadow;
|
||||
|
||||
|
|
|
@ -49,18 +49,18 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
half4 position : SV_Position;
|
||||
half4 texcoord0 : TEXCOORD0_centroid;
|
||||
half4 texcoord1 : TEXCOORD1_centroid;
|
||||
half4 texcoord2 : TEXCOORD2_centroid;
|
||||
half4 texcoord3 : TEXCOORD3_centroid;
|
||||
half4 texcoord4 : TEXCOORD4_centroid;
|
||||
half4 texcoord5 : TEXCOORD5_centroid;
|
||||
half4 texcoord6 : TEXCOORD6_centroid;
|
||||
half4 texcoord7 : TEXCOORD7_centroid;
|
||||
half4 texcoord8 : TEXCOORD8_centroid;
|
||||
half4 texcoord9 : TEXCOORD9_centroid;
|
||||
half4 color : COLOR0;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
float4 texcoord3 : TEXCOORD3_centroid;
|
||||
float4 texcoord4 : TEXCOORD4_centroid;
|
||||
float4 texcoord5 : TEXCOORD5_centroid;
|
||||
float4 texcoord6 : TEXCOORD6_centroid;
|
||||
float4 texcoord7 : TEXCOORD7_centroid;
|
||||
float4 texcoord8 : TEXCOORD8_centroid;
|
||||
float4 texcoord9 : TEXCOORD9_centroid;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
// *INDENT-OFF*
|
||||
|
||||
Texture2D t_ViewColor : register( t0 );
|
||||
Texture2D t_ViewDepth : register( t1 );
|
||||
Texture2D t_ViewColor : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_ViewDepth : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
|
||||
|
||||
struct PS_IN {
|
||||
|
|
|
@ -33,11 +33,11 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_BaseColor : register( t0 );
|
||||
Texture2D t_BlueNoise : register( t1 );
|
||||
Texture2D t_BaseColor : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_BlueNoise : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState samp0 : register(s0);
|
||||
SamplerState samp1 : register(s1); // blue noise 256
|
||||
SamplerState samp0 : register(s0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
SamplerState samp1 : register(s1 VK_DESCRIPTOR_SET( 1 ) ); // blue noise 256
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
|
|
@ -31,8 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_BaseColor : register( t0 );
|
||||
SamplerState samp0 : register(s0);
|
||||
Texture2D t_BaseColor : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
SamplerState samp0 : register( s0 VK_DESCRIPTOR_SET( 1 ) );
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
|
|
@ -31,11 +31,11 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_CurrentRender : register( t0 );
|
||||
Texture2D t_HeatMap : register( t1 );
|
||||
Texture2D t_CurrentRender : register( t0 VK_DESCRIPTOR_SET( 0 ) );
|
||||
Texture2D t_HeatMap : register( t1 VK_DESCRIPTOR_SET( 0 ) );
|
||||
|
||||
SamplerState samp0 : register(s0); // texture 0 is _currentRender
|
||||
SamplerState samp1 : register(s1); // texture 1 is heatmap
|
||||
SamplerState samp0 : register( s0 VK_DESCRIPTOR_SET( 1 ) ); // texture 0 is _currentRender
|
||||
SamplerState samp1 : register( s1 VK_DESCRIPTOR_SET( 1 ) ); // texture 1 is heatmap
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
|
|
@ -27,8 +27,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "vulkan.hlsli"
|
||||
|
||||
// *INDENT-OFF*
|
||||
cbuffer CB : register( b0 )
|
||||
cbuffer globals : register( b0 VK_DESCRIPTOR_SET( 0 ) )
|
||||
{
|
||||
float4 rpScreenCorrectionFactor;
|
||||
float4 rpWindowCoord;
|
||||
|
@ -100,7 +102,7 @@ cbuffer CB : register( b0 )
|
|||
float4 rpEnableSkinning;
|
||||
float4 rpAlphaTest;
|
||||
|
||||
// RB begin
|
||||
// RB begin
|
||||
float4 rpAmbientColor;
|
||||
float4 rpGlobalLightOrigin;
|
||||
float4 rpJitterTexScale;
|
||||
|
@ -112,7 +114,7 @@ cbuffer CB : register( b0 )
|
|||
#else
|
||||
float4 rpShadowMatrices[6 * 4];
|
||||
#endif
|
||||
// RB end
|
||||
// RB end
|
||||
|
||||
float4 rpUser0;
|
||||
float4 rpUser1;
|
||||
|
@ -124,16 +126,37 @@ cbuffer CB : register( b0 )
|
|||
float4 rpUser7;
|
||||
};
|
||||
|
||||
static float dot2( float2 a, float2 b ) { return dot( a, b ); }
|
||||
static float dot3( float3 a, float3 b ) { return dot( a, b ); }
|
||||
static float dot3( float3 a, float4 b ) { return dot( a, b.xyz ); }
|
||||
static float dot3( float4 a, float3 b ) { return dot( a.xyz, b ); }
|
||||
static float dot3( float4 a, float4 b ) { return dot( a.xyz, b.xyz ); }
|
||||
static float dot4( float4 a, float4 b ) { return dot( a, b ); }
|
||||
static float dot4( float2 a, float4 b ) { return dot( float4( a, 0, 1 ), b ); }
|
||||
|
||||
// *INDENT-ON*
|
||||
|
||||
static float dot2( float2 a, float2 b )
|
||||
{
|
||||
return dot( a, b );
|
||||
}
|
||||
static float dot3( float3 a, float3 b )
|
||||
{
|
||||
return dot( a, b );
|
||||
}
|
||||
static float dot3( float3 a, float4 b )
|
||||
{
|
||||
return dot( a, b.xyz );
|
||||
}
|
||||
static float dot3( float4 a, float3 b )
|
||||
{
|
||||
return dot( a.xyz, b );
|
||||
}
|
||||
static float dot3( float4 a, float4 b )
|
||||
{
|
||||
return dot( a.xyz, b.xyz );
|
||||
}
|
||||
static float dot4( float4 a, float4 b )
|
||||
{
|
||||
return dot( a, b );
|
||||
}
|
||||
static float dot4( float2 a, float4 b )
|
||||
{
|
||||
return dot( float4( a, 0, 1 ), b );
|
||||
}
|
||||
|
||||
// RB begin
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
|
|
36
neo/shaders/vulkan.hlsli
Normal file
36
neo/shaders/vulkan.hlsli
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef VULKAN_HLSLI
|
||||
#define VULKAN_HLSLI
|
||||
|
||||
#ifdef SPIRV
|
||||
#define VK_PUSH_CONSTANT [[vk::push_constant]]
|
||||
#define VK_BINDING(reg,dset) [[vk::binding(reg,dset)]]
|
||||
#define VK_DESCRIPTOR_SET(dset) ,space##dset
|
||||
#else
|
||||
#define VK_PUSH_CONSTANT
|
||||
#define VK_BINDING(reg,dset)
|
||||
#define VK_DESCRIPTOR_SET(dset)
|
||||
#endif
|
||||
|
||||
#endif // VULKAN_HLSLI
|
|
@ -36,7 +36,6 @@ void DeviceManager::GetWindowDimensions( int& width, int& height )
|
|||
|
||||
void DeviceManager::BackBufferResizing()
|
||||
{
|
||||
tr.backend.BackBufferResizing();
|
||||
Framebuffer::Shutdown();
|
||||
}
|
||||
|
||||
|
@ -85,11 +84,6 @@ DeviceManager* DeviceManager::CreateD3D11()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
DeviceManager* DeviceManager::CreateVK()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DefaultMessageCallback& DefaultMessageCallback::GetInstance()
|
||||
{
|
||||
static DefaultMessageCallback instance;
|
||||
|
|
|
@ -54,6 +54,11 @@ struct DeviceCreationParameters
|
|||
bool enableComputeQueue = false;
|
||||
bool enableCopyQueue = false;
|
||||
|
||||
#if _WIN32
|
||||
HINSTANCE hInstance;
|
||||
HWND hWnd;
|
||||
#endif
|
||||
|
||||
#if USE_DX11 || USE_DX12
|
||||
// Adapter to create the device on. Setting this to non-null overrides adapterNameSubstring.
|
||||
// If device creation fails on the specified adapter, it will *not* try any other adapters.
|
||||
|
@ -126,6 +131,7 @@ public:
|
|||
protected:
|
||||
friend class idRenderBackend;
|
||||
|
||||
void* windowInstance;
|
||||
void* windowHandle;
|
||||
bool windowVisible = false;
|
||||
bool isNvidia = false;
|
||||
|
|
|
@ -39,8 +39,7 @@
|
|||
#pragma comment(lib, "d3d12.lib")
|
||||
#pragma comment(lib, "dxgi.lib")
|
||||
|
||||
// TODO extend this so 1 will be just NVRHI and 2 will turn on the additional VK validation layer
|
||||
idCVar r_useValidationLayers( "r_useValidationLayers", "0", CVAR_BOOL | CVAR_INIT, "" );
|
||||
idCVar r_useValidationLayers( "r_useValidationLayers", "0", CVAR_INTEGER | CVAR_INIT, "1 is just the NVRHI and 2 will turn on additional DX12, VK validation layers" );
|
||||
|
||||
using nvrhi::RefCountPtr;
|
||||
|
||||
|
@ -400,7 +399,8 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain()
|
|||
|
||||
nvrhiDevice = nvrhi::d3d12::createDevice( deviceDesc );
|
||||
|
||||
deviceParms.enableNvrhiValidationLayer = r_useValidationLayers.GetBool();
|
||||
deviceParms.enableNvrhiValidationLayer = r_useValidationLayers.GetInteger() > 0;
|
||||
deviceParms.enableDebugRuntime = r_useValidationLayers.GetInteger() > 1;
|
||||
|
||||
if( deviceParms.enableNvrhiValidationLayer )
|
||||
{
|
||||
|
|
1197
neo/sys/win32/DeviceManager_VK.cpp
Normal file
1197
neo/sys/win32/DeviceManager_VK.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -64,7 +64,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
/*
|
||||
========================
|
||||
GLimp_TestSwapBuffers
|
||||
|
@ -197,7 +197,7 @@ FakeWndProc
|
|||
Only used to get wglExtensions
|
||||
====================
|
||||
*/
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
LONG WINAPI FakeWndProc(
|
||||
HWND hWnd,
|
||||
UINT uMsg,
|
||||
|
@ -298,7 +298,7 @@ void GLW_CheckWGLExtensions( HDC hDC )
|
|||
GLW_GetWGLExtensionsWithFakeWindow
|
||||
==================
|
||||
*/
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
static void GLW_GetWGLExtensionsWithFakeWindow()
|
||||
{
|
||||
HWND hWnd;
|
||||
|
@ -347,7 +347,7 @@ void GLW_WM_CREATE( HWND hWnd )
|
|||
CreateOpenGLContextOnDC
|
||||
========================
|
||||
*/
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
static HGLRC CreateOpenGLContextOnDC( const HDC hdc, const bool debugContext )
|
||||
{
|
||||
int useCoreProfile = r_useOpenGL45.GetInteger();
|
||||
|
@ -616,7 +616,7 @@ static void GLW_CreateWindowClasses()
|
|||
}
|
||||
common->Printf( "...registered window class\n" );
|
||||
|
||||
#if !defined(USE_VULKAN) && !defined(USE_DX12)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
// now register the fake window class that is only used
|
||||
// to get wgl extensions
|
||||
wc.style = 0;
|
||||
|
@ -1099,6 +1099,7 @@ bool DeviceManager::CreateWindowDeviceAndSwapChain( const glimpParms_t& parms, c
|
|||
win32.hInstance,
|
||||
NULL );
|
||||
|
||||
windowInstance = win32.hInstance;
|
||||
windowHandle = win32.hWnd;
|
||||
|
||||
if( !win32.hWnd )
|
||||
|
@ -1121,6 +1122,11 @@ bool DeviceManager::CreateWindowDeviceAndSwapChain( const glimpParms_t& parms, c
|
|||
return false;
|
||||
}
|
||||
|
||||
// RB
|
||||
deviceParms.backBufferWidth = parms.width;
|
||||
deviceParms.backBufferHeight = parms.height;
|
||||
deviceParms.vsyncEnabled = requestedVSync;
|
||||
|
||||
if( !CreateDeviceAndSwapChain() )
|
||||
{
|
||||
return false;
|
||||
|
@ -1219,7 +1225,7 @@ static bool GLW_CreateWindow( glimpParms_t parms )
|
|||
return false;
|
||||
}
|
||||
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
// Check to see if we can get a stereo pixel format, even if we aren't going to use it,
|
||||
// so the menu option can be
|
||||
if( GLW_ChoosePixelFormat( win32.hDC, parms.multiSamples, true ) != -1 )
|
||||
|
@ -1383,7 +1389,7 @@ bool GLimp_Init( glimpParms_t parms )
|
|||
{
|
||||
HDC hDC;
|
||||
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
cmdSystem->AddCommand( "testSwapBuffers", GLimp_TestSwapBuffers, CMD_FL_SYSTEM, "Times swapbuffer options" );
|
||||
|
||||
common->Printf( "Initializing OpenGL subsystem with multisamples:%i stereo:%i fullscreen:%i\n",
|
||||
|
@ -1649,7 +1655,7 @@ GLimp_SwapBuffers
|
|||
=====================
|
||||
*/
|
||||
// RB: use GLEW for V-Sync
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
void GLimp_SwapBuffers()
|
||||
{
|
||||
if( r_swapInterval.IsModified() )
|
||||
|
|
|
@ -32,7 +32,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include <windows.h>
|
||||
|
||||
// RB: replaced QGL with GLEW
|
||||
#if !defined(USE_VULKAN)
|
||||
#if !defined(USE_VULKAN) && !defined(USE_NVRHI)
|
||||
#include "../../libs/glew/include/GL/wglew.h" // windows OpenGL extensions
|
||||
#endif
|
||||
// RB end
|
||||
|
|
Loading…
Reference in a new issue