2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/*=============================================================================
|
|
|
|
|
OpenGLState.cpp: OpenGL state implementation.
|
|
|
|
|
=============================================================================*/
|
|
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "Serialization/MemoryWriter.h"
|
|
|
|
|
#include "RHI.h"
|
|
|
|
|
#include "OpenGLDrv.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
GLint GMaxOpenGLTextureFilterAnisotropic = 1;
|
|
|
|
|
|
|
|
|
|
// Hash of sampler states, used for caching sampler states and texture objects
|
|
|
|
|
static TMap<FSamplerStateInitializerRHI, FOpenGLSamplerState*> GSamplerStateCache;
|
|
|
|
|
|
2021-09-29 17:45:16 -04:00
|
|
|
namespace OpenGLConsoleVariables
|
|
|
|
|
{
|
|
|
|
|
extern int32 GOpenGLForceBilinear;
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
void EmptyGLSamplerStateCache()
|
|
|
|
|
{
|
|
|
|
|
for (auto Iter = GSamplerStateCache.CreateIterator(); Iter; ++Iter )
|
|
|
|
|
{
|
|
|
|
|
auto* State = Iter.Value();
|
|
|
|
|
// Manually release
|
|
|
|
|
State->Release();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GSamplerStateCache.Empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GLenum TranslateAddressMode(ESamplerAddressMode AddressMode)
|
|
|
|
|
{
|
|
|
|
|
switch(AddressMode)
|
|
|
|
|
{
|
|
|
|
|
case AM_Clamp: return GL_CLAMP_TO_EDGE;
|
|
|
|
|
case AM_Mirror: return GL_MIRRORED_REPEAT;
|
|
|
|
|
case AM_Border: return UGL_CLAMP_TO_BORDER;
|
|
|
|
|
default: return GL_REPEAT;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GLenum TranslateCullMode(ERasterizerCullMode CullMode)
|
|
|
|
|
{
|
|
|
|
|
switch(CullMode)
|
|
|
|
|
{
|
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3169859)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3134663 on 2016/09/21 by Chris.Bunner
Merging Dev-MaterialLayers to Dev-Rendering, CL 3134208. Initial material attribute extensibility changes.
#jira UE-34347
Change 3142292 on 2016/09/27 by Rolando.Caloca
DR - hlslcc - Fix for warning X3206: implicit truncation of vector type causing error
#jira UE-31438
Change 3143557 on 2016/09/28 by Rolando.Caloca
DR - Back out changelist 3142292
Change 3145354 on 2016/09/29 by Benjamin.Hyder
Updating Tm-ContactShadows
Change 3154832 on 2016/10/07 by Rolando.Caloca
DR - vk - Fix crash on framebuffers with missing textures
Change 3154838 on 2016/10/07 by Rolando.Caloca
DR - vk - Enable clip distance
Change 3154840 on 2016/10/07 by Rolando.Caloca
DR - Remove branch per codereview
Change 3155118 on 2016/10/07 by Rolando.Caloca
DR - vk - Compute pipeline fixes
Change 3155129 on 2016/10/07 by Rolando.Caloca
DR - Added draw events for reflection captures
Change 3155167 on 2016/10/07 by Rolando.Caloca
DR - Use shader clear for platforms that can't use viewport or scissor
Change 3155168 on 2016/10/07 by Rolando.Caloca
DR - vk - Added submit gpu
- Some fixes for Geometry and Compute
Change 3155595 on 2016/10/07 by Rolando.Caloca
DR - vk - Use new render pass system
Change 3155720 on 2016/10/07 by Rolando.Caloca
DR - vk - static analysis fix
Change 3155732 on 2016/10/07 by Rolando.Caloca
DR - Fix clears for platforms that can't use viewports, excluderects or scissor on clear
Change 3156787 on 2016/10/10 by Rolando.Caloca
DR - Fix mem leaks
Change 3156805 on 2016/10/10 by Rolando.Caloca
DR - Improve check msg per licensee
Change 3156815 on 2016/10/10 by Rolando.Caloca
DR - Fix infinite recursion
Change 3157041 on 2016/10/10 by Rolando.Caloca
DR - vk - Fix key access from multiple threads
Change 3158253 on 2016/10/11 by Rolando.Caloca
DR - Fix comment
#jira UE-37128
PR #2852
Change 3158606 on 2016/10/11 by Rolando.Caloca
DR - vk - Accessors
Change 3160418 on 2016/10/12 by Daniel.Wright
Lightmap textures are now outered to UMapBuildDataRegistry so that the UMapBuildDataRegistry can be moved in the content browser
Change 3160644 on 2016/10/12 by Arne.Schober
DR - [UE-32613] - OpenGL used to have custom code in the compiler to modify the source so that the same data and matricies can be used as DirectX, unfortunately that causes precission problem. Fortunately there is an extension available (glClipControl) which enables DirectX behaviour in OpenGL and it is widely supported. We only tested Linux and Windows and therfore only default enable on those platforms.
Change 3161219 on 2016/10/13 by Luke.Thatcher
[RENDERING] [!] Fix incorrect shader used in GPU Benchmark causing crash in OpenGL.
Change 3161838 on 2016/10/13 by Daniel.Wright
Fixed level getting added to the dirty list twice when legacy lightmaps are present
Change 3161884 on 2016/10/13 by Arne.Schober
DR - Fix Mac and DCC build
Change 3162206 on 2016/10/13 by Chris.Bunner
Merging Dev-MaterialLayers to Dev-Rendering, CL 3161593:
Material expressions; Trig, fast-trig, saturate, round, truncate, pre-skinned normal.
Added CustomEyeTangent to material attributes.
Resolved some hard-coded attribute typing and other minor fixes.
Change 3162491 on 2016/10/13 by Chris.Bunner
Merging Dev-MaterialLayers to Dev-Rendering, CL 3162397:
More fixed type-casting on material attributes.
Swapped compiler::forcecast booleans to flags (and fixed a regression).
Change 3163266 on 2016/10/14 by Daniel.Wright
Fixed sublevels with legacy lighting data being added to the dirty packages list redundantly
Change 3163524 on 2016/10/14 by Mark.Satterthwaite
Bring over specific changes from Unicorn branch that increases the size of shader optional data so that it is considerably more useful.
Change 3163529 on 2016/10/14 by Mark.Satterthwaite
Move the Metal shader source code and compilation path into the newly enlarged shader optional data.
Change 3163553 on 2016/10/14 by Mark.Satterthwaite
Speculative fix for FORT-31590 also seen by a licensee - the Metal command buffer handler will be called from a dispatch queue thread that won't be registered with the stats system.
#jira FORT-31590
Change 3163562 on 2016/10/14 by Mark.Satterthwaite
Tidy up and extend the Metal debugging options:
- Added rhi.Metal.BufferScribble which when enabled will fill freed buffer regions with 0xCD to help identify any areas where we are writing to a buffer while it is still being processed on the GPU.
- Added rhi.Metal.BufferZeroFill which will zero-fill newly allocated buffer regions before any other data is read/written. Useful for catching cases where we might be reading uninitialised memory.
- Added rhi.Metal.ResourcePurgeOnDelete which will purge the backing store of resources prior to releasing them back to the system or the respective pool. This will make any use-after-free conditions much more likely.
- Added rhi.Metal.ResourceDeferDeleteNumFrames to defer releasing resources to the system or the resource pool by the specified number of frames (in addition to the current policy of waiting for the current end of frame & command-buffer completion). Useful for tracking down resource lifetime errors.
- Fixed a number of bugs related to the modifications to vertex stream handling and addition of the SetShaderBytes API.
- Track the start & end of FRingBuffer ranges - it appeared that the ring-buffer usage was invalid but it was in fact only my assumptions about the range that needed to be scribbled for rhi.Metal.BufferScribble. There is still the possibility that command-buffers that are implicitly parallelised by the driver may cause the ring-buffer range tracking to go awry - but with our data dependencies and the separation of the async. compute context I don't believe this is likely.
- Fix up the "nometalv2" flag so that we can disable the features only available on iOS/tvOS-10/macOS-10.12 on newer devices to save having to reboot all the time.
- Fixed the flickering geometry when enabling rhi.Metal.RuntimeDebugLevel=4 which breaks render passes into separate command-buffers - the occlusion query was waiting on the wrong command buffer in this case.
Change 3163752 on 2016/10/14 by Mark.Satterthwaite
Add missing parenthesis to fix compile error on iOS.
Change 3164151 on 2016/10/16 by Benjamin.Hyder
Submitting TM-AutoLOD level to QAGame
#jira UE-29618
Change 3164190 on 2016/10/16 by Uriel.Doyon
Materials now hold texture streaming data in the form of (UV scale X UV channel) for each texture.
This data can be disabled through "r.Streaming.UseMaterialData"
Defined a common framework in MeshComponent for texture streaming, used by both StaticMeshes and SkeletalMeshes.
Simplified component interface for using the texture streaming build framework.
Removed intermediate texture streaming build data from the static mesh components.
Fixed shader compilation errors with the decals (from merge with main).
Change 3164636 on 2016/10/17 by Rolando.Caloca
DR - vk - Fix validation spam
Change 3164679 on 2016/10/17 by Arne.Schober
DR - [OR-28457] Part1, Scene View Refactoring - Removed Previous VewMatrices from SceneInfo and pass in Previous and Current ViewMatrices into Uniform Buffer creation to uniform UseCase for Shadows and CustomDepth, Fixed a Bug in Shadows with help of Daniel where the SceneView was copied unnecessary copied again. Also simplified the code in that area.
Change 3164705 on 2016/10/17 by Daniel.Wright
When new levels are loaded, only the Indirect Lighting Cache Allocations intersecting the level's light probes are updated to minimize hitches. This optimization requires a lighting build to compute PrecomputedLightVolume bounds.
Change 3164834 on 2016/10/17 by Daniel.Wright
Support directional light dynamic shadows in any channel with forward shading, which can happen with multiple shadow casting stationary directional lights (even though only the lighting of one will appear)
Change 3164870 on 2016/10/17 by Arne.Schober
DR - [OR-28457] Part2, Custom Depth Jitter - Allowed to overwite the viewconstant buffer in the custom depth pass. There ia also a new Project Setting available. The default constructor of the ContextDataType has been explicitly deleted to enforce compile errors when the templated code like the StaticMeshDrawList accidently tries to create a context without ViewUniformBuffer.
Change 3164949 on 2016/10/17 by Rolando.Caloca
DR - vk - First version of pooled occlusion queries
Change 3165100 on 2016/10/17 by Rolando.Caloca
DR - vk - Added driver version for Nvidia. AMD doesn't have one yet.
Change 3165160 on 2016/10/17 by Rolando.Caloca
DR - vk - Fix for queries not ready
Change 3165230 on 2016/10/17 by Rolando.Caloca
DR - vk - More fixes for occlusion queries
Change 3165839 on 2016/10/18 by Rolando.Caloca
DR - hlslcc - Fix default parameters getting wrong values
Change 3166029 on 2016/10/18 by Rolando.Caloca
DR - Switch some clears to DrawClearQuad()
Change 3166066 on 2016/10/18 by Mark.Satterthwaite
Update ShaderVersion due to CL #3163524
Change 3166067 on 2016/10/18 by Mark.Satterthwaite
Update Mac hlslcc for RCO's 3165839.
Change 3166370 on 2016/10/18 by Brian.Karis
Improved hair AA
Change 3166389 on 2016/10/18 by Uriel.Doyon
Fixed lightmap having bigger resolutions than the engine can handle
#jira UE-34737
#review-3166193 @daniel.wright
Change 3166495 on 2016/10/18 by Rolando.Caloca
DR - vk - Fix occlusion queries
Change 3166516 on 2016/10/18 by Arne.Schober
DR - Fix shaderbuild issue
Change 3166650 on 2016/10/18 by Rolando.Caloca
DR - vk - Enable GRHISupportsFirstInstance
Change 3166799 on 2016/10/18 by Arne.Schober
DR - [OR-28508] - The velocity Rendering pass was missing the adjustment for the PDO
Change 3167855 on 2016/10/19 by Rolando.Caloca
DR - vk - Implemented texture streaming
Change 3168365 on 2016/10/19 by Rolando.Caloca
DR - Fix static analysis
Change 3168405 on 2016/10/19 by Mark.Satterthwaite
Fix the optional shader data changes from Unicorn to prevent FindOptionalData from erronesouly testing against the trailing optional data size, which can match the tag for optional data entries if you are unlucky.
#jira UE-37489
Change 3169467 on 2016/10/20 by Arne.Schober
DR - UE-28039 - Fixed flickering cached shadows on dynamic objects: Adding preshadows whose depths are cached so that GatherDynamicMeshElements will still happen, which is necessary for preshadow receiver stenciling.
Change 3169478 on 2016/10/20 by Arne.Schober
DR - UE-28039 - missing comment
Change 3169845 on 2016/10/20 by Arne.Schober
DR - UE-35937 - readd Merged out check
Change 3169859 on 2016/10/20 by Rolando.Caloca
DR - vk - Stop popping up dialog on every run as the device name in the API doesn't match our driver database
[CL 3170066 by Marcus Wassmer in Main branch]
2016-10-20 20:09:22 -04:00
|
|
|
case CM_CW: return FOpenGL::SupportsClipControl() ? GL_BACK : GL_FRONT;
|
|
|
|
|
case CM_CCW: return FOpenGL::SupportsClipControl() ? GL_FRONT : GL_BACK;
|
2014-03-14 14:13:41 -04:00
|
|
|
default: return GL_NONE;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GLenum TranslateFillMode(ERasterizerFillMode FillMode)
|
|
|
|
|
{
|
|
|
|
|
if ( FOpenGL::SupportsPolygonMode() )
|
|
|
|
|
{
|
|
|
|
|
switch(FillMode)
|
|
|
|
|
{
|
|
|
|
|
case FM_Point: return GL_POINT;
|
|
|
|
|
case FM_Wireframe: return GL_LINE;
|
2015-03-31 20:12:31 -04:00
|
|
|
default: break;
|
2014-03-14 14:13:41 -04:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return GL_FILL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 21:04:31 -04:00
|
|
|
static ERasterizerCullMode TranslateCullMode(GLenum CullMode)
|
|
|
|
|
{
|
|
|
|
|
if (FOpenGL::SupportsClipControl())
|
|
|
|
|
{
|
|
|
|
|
switch(CullMode)
|
|
|
|
|
{
|
|
|
|
|
case GL_BACK: return CM_CW;
|
|
|
|
|
case GL_FRONT: return CM_CCW;
|
|
|
|
|
default: return CM_None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch(CullMode)
|
|
|
|
|
{
|
|
|
|
|
case GL_FRONT: return CM_CW;
|
|
|
|
|
case GL_BACK: return CM_CCW;
|
|
|
|
|
default: return CM_None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ERasterizerFillMode TranslateFillMode(GLenum FillMode)
|
|
|
|
|
{
|
|
|
|
|
switch(FillMode)
|
|
|
|
|
{
|
|
|
|
|
case GL_POINT: return FM_Point;
|
|
|
|
|
case GL_LINE: return FM_Wireframe;
|
|
|
|
|
default: return FM_Solid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
static GLenum TranslateCompareFunction(ECompareFunction CompareFunction)
|
|
|
|
|
{
|
|
|
|
|
switch(CompareFunction)
|
|
|
|
|
{
|
|
|
|
|
case CF_Less: return GL_LESS;
|
|
|
|
|
case CF_LessEqual: return GL_LEQUAL;
|
|
|
|
|
case CF_Greater: return GL_GREATER;
|
|
|
|
|
case CF_GreaterEqual: return GL_GEQUAL;
|
|
|
|
|
case CF_Equal: return GL_EQUAL;
|
|
|
|
|
case CF_NotEqual: return GL_NOTEQUAL;
|
|
|
|
|
case CF_Never: return GL_NEVER;
|
|
|
|
|
default: return GL_ALWAYS;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GLenum TranslateStencilOp(EStencilOp StencilOp)
|
|
|
|
|
{
|
|
|
|
|
switch(StencilOp)
|
|
|
|
|
{
|
|
|
|
|
case SO_Zero: return GL_ZERO;
|
|
|
|
|
case SO_Replace: return GL_REPLACE;
|
|
|
|
|
case SO_SaturatedIncrement: return GL_INCR;
|
|
|
|
|
case SO_SaturatedDecrement: return GL_DECR;
|
|
|
|
|
case SO_Invert: return GL_INVERT;
|
|
|
|
|
case SO_Increment: return GL_INCR_WRAP;
|
|
|
|
|
case SO_Decrement: return GL_DECR_WRAP;
|
|
|
|
|
default: return GL_KEEP;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 21:04:31 -04:00
|
|
|
static ECompareFunction TranslateCompareFunction(GLenum CompareFunction)
|
|
|
|
|
{
|
|
|
|
|
switch(CompareFunction)
|
|
|
|
|
{
|
|
|
|
|
case GL_LESS: return CF_Less;
|
|
|
|
|
case GL_LEQUAL: return CF_LessEqual;
|
|
|
|
|
case GL_GREATER: return CF_Greater;
|
|
|
|
|
case GL_GEQUAL: return CF_GreaterEqual;
|
|
|
|
|
case GL_EQUAL: return CF_Equal;
|
|
|
|
|
case GL_NOTEQUAL: return CF_NotEqual;
|
|
|
|
|
case GL_NEVER: return CF_Never;
|
|
|
|
|
default: return CF_Always;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EStencilOp TranslateStencilOp(GLenum StencilOp)
|
|
|
|
|
{
|
|
|
|
|
switch(StencilOp)
|
|
|
|
|
{
|
|
|
|
|
case GL_ZERO: return SO_Zero;
|
|
|
|
|
case GL_REPLACE: return SO_Replace;
|
|
|
|
|
case GL_INCR: return SO_SaturatedIncrement;
|
|
|
|
|
case GL_DECR: return SO_SaturatedDecrement;
|
|
|
|
|
case GL_INVERT: return SO_Invert;
|
|
|
|
|
case GL_INCR_WRAP: return SO_Increment;
|
|
|
|
|
case GL_DECR_WRAP: return SO_Decrement;
|
|
|
|
|
default: return SO_Keep;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
static GLenum TranslateBlendOp(EBlendOperation BlendOp)
|
|
|
|
|
{
|
|
|
|
|
switch(BlendOp)
|
|
|
|
|
{
|
|
|
|
|
case BO_Subtract: return GL_FUNC_SUBTRACT;
|
|
|
|
|
case BO_Min: return GL_MIN;
|
|
|
|
|
case BO_Max: return GL_MAX;
|
|
|
|
|
case BO_ReverseSubtract: return GL_FUNC_REVERSE_SUBTRACT;
|
|
|
|
|
default: return GL_FUNC_ADD;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GLenum TranslateBlendFactor(EBlendFactor BlendFactor)
|
|
|
|
|
{
|
|
|
|
|
switch(BlendFactor)
|
|
|
|
|
{
|
|
|
|
|
case BF_One: return GL_ONE;
|
|
|
|
|
case BF_SourceColor: return GL_SRC_COLOR;
|
|
|
|
|
case BF_InverseSourceColor: return GL_ONE_MINUS_SRC_COLOR;
|
|
|
|
|
case BF_SourceAlpha: return GL_SRC_ALPHA;
|
|
|
|
|
case BF_InverseSourceAlpha: return GL_ONE_MINUS_SRC_ALPHA;
|
|
|
|
|
case BF_DestAlpha: return GL_DST_ALPHA;
|
|
|
|
|
case BF_InverseDestAlpha: return GL_ONE_MINUS_DST_ALPHA;
|
|
|
|
|
case BF_DestColor: return GL_DST_COLOR;
|
|
|
|
|
case BF_InverseDestColor: return GL_ONE_MINUS_DST_COLOR;
|
|
|
|
|
case BF_ConstantBlendFactor: return GL_CONSTANT_COLOR;
|
|
|
|
|
case BF_InverseConstantBlendFactor: return GL_ONE_MINUS_CONSTANT_COLOR;
|
|
|
|
|
default: return GL_ZERO;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 21:04:31 -04:00
|
|
|
static EBlendOperation TranslateBlendOp(GLenum BlendOp)
|
|
|
|
|
{
|
|
|
|
|
switch(BlendOp)
|
|
|
|
|
{
|
|
|
|
|
case GL_FUNC_SUBTRACT: return BO_Subtract;
|
|
|
|
|
case GL_MIN: return BO_Min;
|
|
|
|
|
case GL_MAX: return BO_Max;
|
|
|
|
|
case GL_FUNC_REVERSE_SUBTRACT: return BO_ReverseSubtract;
|
|
|
|
|
default: return BO_Add;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EBlendFactor TranslateBlendFactor(GLenum BlendFactor)
|
|
|
|
|
{
|
|
|
|
|
switch(BlendFactor)
|
|
|
|
|
{
|
|
|
|
|
case GL_ONE: return BF_One;
|
|
|
|
|
case GL_SRC_COLOR: return BF_SourceColor;
|
|
|
|
|
case GL_ONE_MINUS_SRC_COLOR: return BF_InverseSourceColor;
|
|
|
|
|
case GL_SRC_ALPHA: return BF_SourceAlpha;
|
|
|
|
|
case GL_ONE_MINUS_SRC_ALPHA: return BF_InverseSourceAlpha;
|
|
|
|
|
case GL_DST_ALPHA: return BF_DestAlpha;
|
|
|
|
|
case GL_ONE_MINUS_DST_ALPHA: return BF_InverseDestAlpha;
|
|
|
|
|
case GL_DST_COLOR: return BF_DestColor;
|
|
|
|
|
case GL_ONE_MINUS_DST_COLOR: return BF_InverseDestColor;
|
|
|
|
|
case GL_CONSTANT_COLOR: return BF_ConstantBlendFactor;
|
|
|
|
|
case GL_ONE_MINUS_CONSTANT_COLOR: return BF_InverseConstantBlendFactor;
|
|
|
|
|
default: return BF_Zero;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
FOpenGLSamplerState::~FOpenGLSamplerState()
|
|
|
|
|
{
|
2021-05-18 13:24:16 -04:00
|
|
|
CreationFence.WaitFenceRenderThreadOnly();
|
2014-03-14 14:13:41 -04:00
|
|
|
VERIFY_GL_SCOPE();
|
|
|
|
|
FOpenGL::DeleteSamplers(1,&Resource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSamplerStateRHIRef FOpenGLDynamicRHI::RHICreateSamplerState(const FSamplerStateInitializerRHI& Initializer)
|
|
|
|
|
{
|
|
|
|
|
// Try to find an existing cached state
|
|
|
|
|
FOpenGLSamplerState** Found = GSamplerStateCache.Find(Initializer);
|
|
|
|
|
if (Found)
|
|
|
|
|
{
|
|
|
|
|
return *Found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FOpenGLSamplerState* SamplerState = new FOpenGLSamplerState;
|
|
|
|
|
|
|
|
|
|
SamplerState->Data.WrapS = TranslateAddressMode( Initializer.AddressU );
|
|
|
|
|
SamplerState->Data.WrapT = TranslateAddressMode( Initializer.AddressV );
|
|
|
|
|
SamplerState->Data.WrapR = TranslateAddressMode( Initializer.AddressW );
|
|
|
|
|
SamplerState->Data.LODBias = Initializer.MipBias;
|
|
|
|
|
|
|
|
|
|
SamplerState->Data.MaxAnisotropy = 1;
|
|
|
|
|
const bool bComparisonEnabled = (Initializer.SamplerComparisonFunction != SCF_Never);
|
|
|
|
|
|
|
|
|
|
switch(Initializer.Filter)
|
|
|
|
|
{
|
|
|
|
|
case SF_AnisotropicPoint:
|
|
|
|
|
// This is set up like this in D3D11, so following suit.
|
|
|
|
|
// Otherwise we're getting QA reports about weird artifacting, because QA scenes are set up in
|
|
|
|
|
// D3D11 and AnisotropicPoint when Linear would be proper goes unnoticed there.
|
|
|
|
|
|
|
|
|
|
// Once someone decides to fix things in D3D11, I assume they'll look here to fix things up too. The code below is waiting.
|
|
|
|
|
|
|
|
|
|
// MagFilter = GL_NEAREST;
|
|
|
|
|
// MinFilter = bComparisonEnabled ? GL_NEAREST : GL_NEAREST_MIPMAP_NEAREST;
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
// PASS-THROUGH to AnisotropicLinear!
|
|
|
|
|
|
|
|
|
|
case SF_AnisotropicLinear:
|
|
|
|
|
SamplerState->Data.MagFilter = GL_LINEAR;
|
|
|
|
|
SamplerState->Data.MinFilter = bComparisonEnabled ? GL_LINEAR : GL_LINEAR_MIPMAP_LINEAR;
|
2015-09-11 12:05:05 -04:00
|
|
|
SamplerState->Data.MaxAnisotropy = FMath::Min<uint32>(ComputeAnisotropyRT(Initializer.MaxAnisotropy), GMaxOpenGLTextureFilterAnisotropic);
|
2014-03-14 14:13:41 -04:00
|
|
|
break;
|
|
|
|
|
case SF_Trilinear:
|
|
|
|
|
SamplerState->Data.MagFilter = GL_LINEAR;
|
|
|
|
|
SamplerState->Data.MinFilter = bComparisonEnabled ? GL_LINEAR : GL_LINEAR_MIPMAP_LINEAR;
|
|
|
|
|
break;
|
|
|
|
|
case SF_Bilinear:
|
|
|
|
|
SamplerState->Data.MagFilter = GL_LINEAR;
|
|
|
|
|
SamplerState->Data.MinFilter = GL_LINEAR_MIPMAP_NEAREST;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
case SF_Point:
|
|
|
|
|
SamplerState->Data.MagFilter = GL_NEAREST;
|
|
|
|
|
SamplerState->Data.MinFilter = GL_NEAREST_MIPMAP_NEAREST;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( bComparisonEnabled )
|
|
|
|
|
{
|
|
|
|
|
check(Initializer.SamplerComparisonFunction == SCF_Less);
|
|
|
|
|
SamplerState->Data.CompareMode = GL_COMPARE_REF_TO_TEXTURE;
|
|
|
|
|
SamplerState->Data.CompareFunc = GL_LESS;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SamplerState->Data.CompareMode = GL_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 17:45:16 -04:00
|
|
|
if (OpenGLConsoleVariables::GOpenGLForceBilinear && (SamplerState->Data.MinFilter == GL_LINEAR_MIPMAP_LINEAR))
|
|
|
|
|
{
|
|
|
|
|
SamplerState->Data.MinFilter = GL_LINEAR_MIPMAP_NEAREST;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
SamplerState->CreationFence.Reset();
|
|
|
|
|
SamplerState->Resource = 0;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
auto CreateGLSamplerState = [SamplerState]()
|
|
|
|
|
{
|
|
|
|
|
VERIFY_GL_SCOPE();
|
|
|
|
|
FOpenGL::GenSamplers( 1, &SamplerState->Resource);
|
|
|
|
|
|
|
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_WRAP_S, SamplerState->Data.WrapS);
|
|
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_WRAP_T, SamplerState->Data.WrapT);
|
|
|
|
|
if (FOpenGL::SupportsTexture3D())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2020-09-24 00:43:27 -04:00
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_WRAP_R, SamplerState->Data.WrapR);
|
|
|
|
|
}
|
|
|
|
|
if (FOpenGL::SupportsTextureLODBias())
|
|
|
|
|
{
|
|
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_LOD_BIAS, SamplerState->Data.LODBias);
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_MIN_FILTER, SamplerState->Data.MinFilter);
|
|
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_MAG_FILTER, SamplerState->Data.MagFilter);
|
|
|
|
|
if (FOpenGL::SupportsTextureFilterAnisotropic())
|
|
|
|
|
{
|
|
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_MAX_ANISOTROPY_EXT, SamplerState->Data.MaxAnisotropy);
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
if (FOpenGL::SupportsTextureCompare())
|
|
|
|
|
{
|
|
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_COMPARE_MODE, SamplerState->Data.CompareMode);
|
|
|
|
|
FOpenGL::SetSamplerParameter(SamplerState->Resource, GL_TEXTURE_COMPARE_FUNC, SamplerState->Data.CompareFunc);
|
|
|
|
|
}
|
|
|
|
|
SamplerState->CreationFence.WriteAssertFence();
|
|
|
|
|
};
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
RunOnGLRenderContextThread(MoveTemp(CreateGLSamplerState));
|
|
|
|
|
SamplerState->CreationFence.SetRHIThreadFence();
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
// Manually add reference as we control the creation/destructions
|
|
|
|
|
SamplerState->AddRef();
|
|
|
|
|
GSamplerStateCache.Add(Initializer, SamplerState);
|
2015-02-25 08:13:48 -05:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
return SamplerState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FRasterizerStateRHIRef FOpenGLDynamicRHI::RHICreateRasterizerState(const FRasterizerStateInitializerRHI& Initializer)
|
|
|
|
|
{
|
|
|
|
|
FOpenGLRasterizerState* RasterizerState = new FOpenGLRasterizerState;
|
|
|
|
|
RasterizerState->Data.CullMode = TranslateCullMode(Initializer.CullMode);
|
|
|
|
|
RasterizerState->Data.FillMode = TranslateFillMode(Initializer.FillMode);
|
|
|
|
|
RasterizerState->Data.DepthBias = Initializer.DepthBias;
|
|
|
|
|
RasterizerState->Data.SlopeScaleDepthBias = Initializer.SlopeScaleDepthBias;
|
2022-01-31 17:28:38 -05:00
|
|
|
RasterizerState->Data.DepthClipMode = Initializer.DepthClipMode;
|
2015-02-25 08:13:48 -05:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
return RasterizerState;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 21:04:31 -04:00
|
|
|
bool FOpenGLRasterizerState::GetInitializer(FRasterizerStateInitializerRHI& Init)
|
|
|
|
|
{
|
|
|
|
|
FMemory::Memzero(Init);
|
|
|
|
|
Init.CullMode = TranslateCullMode(Data.CullMode);
|
|
|
|
|
Init.FillMode = TranslateFillMode(Data.FillMode);
|
|
|
|
|
Init.DepthBias = Data.DepthBias;
|
|
|
|
|
Init.SlopeScaleDepthBias = Data.SlopeScaleDepthBias;
|
2022-01-31 17:28:38 -05:00
|
|
|
Init.DepthClipMode = Data.DepthClipMode;
|
2018-05-23 21:04:31 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
FDepthStencilStateRHIRef FOpenGLDynamicRHI::RHICreateDepthStencilState(const FDepthStencilStateInitializerRHI& Initializer)
|
|
|
|
|
{
|
|
|
|
|
FOpenGLDepthStencilState* DepthStencilState = new FOpenGLDepthStencilState;
|
|
|
|
|
DepthStencilState->Data.bZEnable = Initializer.DepthTest != CF_Always || Initializer.bEnableDepthWrite;
|
|
|
|
|
DepthStencilState->Data.bZWriteEnable = Initializer.bEnableDepthWrite;
|
|
|
|
|
DepthStencilState->Data.ZFunc = TranslateCompareFunction(Initializer.DepthTest);
|
|
|
|
|
DepthStencilState->Data.bStencilEnable = Initializer.bEnableFrontFaceStencil || Initializer.bEnableBackFaceStencil;
|
|
|
|
|
DepthStencilState->Data.bTwoSidedStencilMode = Initializer.bEnableBackFaceStencil;
|
|
|
|
|
DepthStencilState->Data.StencilFunc = TranslateCompareFunction(Initializer.FrontFaceStencilTest);
|
|
|
|
|
DepthStencilState->Data.StencilFail = TranslateStencilOp(Initializer.FrontFaceStencilFailStencilOp);
|
|
|
|
|
DepthStencilState->Data.StencilZFail = TranslateStencilOp(Initializer.FrontFaceDepthFailStencilOp);
|
|
|
|
|
DepthStencilState->Data.StencilPass = TranslateStencilOp(Initializer.FrontFacePassStencilOp);
|
|
|
|
|
DepthStencilState->Data.CCWStencilFunc = TranslateCompareFunction(Initializer.BackFaceStencilTest);
|
|
|
|
|
DepthStencilState->Data.CCWStencilFail = TranslateStencilOp(Initializer.BackFaceStencilFailStencilOp);
|
|
|
|
|
DepthStencilState->Data.CCWStencilZFail = TranslateStencilOp(Initializer.BackFaceDepthFailStencilOp);
|
|
|
|
|
DepthStencilState->Data.CCWStencilPass = TranslateStencilOp(Initializer.BackFacePassStencilOp);
|
|
|
|
|
DepthStencilState->Data.StencilReadMask = Initializer.StencilReadMask;
|
|
|
|
|
DepthStencilState->Data.StencilWriteMask = Initializer.StencilWriteMask;
|
2015-02-25 08:13:48 -05:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
return DepthStencilState;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 21:04:31 -04:00
|
|
|
bool FOpenGLDepthStencilState::GetInitializer(FDepthStencilStateInitializerRHI& Init)
|
|
|
|
|
{
|
|
|
|
|
Init.bEnableBackFaceStencil = Data.bTwoSidedStencilMode;
|
|
|
|
|
Init.bEnableFrontFaceStencil = Data.bStencilEnable;
|
|
|
|
|
Init.bEnableDepthWrite = Data.bZWriteEnable;
|
|
|
|
|
Init.StencilReadMask = Data.StencilReadMask;
|
|
|
|
|
Init.StencilWriteMask = Data.StencilWriteMask;
|
|
|
|
|
Init.DepthTest = TranslateCompareFunction(Data.ZFunc);
|
|
|
|
|
Init.FrontFaceStencilTest = TranslateCompareFunction(Data.StencilFunc);
|
|
|
|
|
Init.FrontFaceStencilFailStencilOp = TranslateStencilOp(Data.StencilFail);
|
|
|
|
|
Init.FrontFaceDepthFailStencilOp = TranslateStencilOp(Data.StencilZFail);
|
|
|
|
|
Init.FrontFacePassStencilOp = TranslateStencilOp(Data.StencilPass);
|
|
|
|
|
Init.BackFaceStencilTest = TranslateCompareFunction(Data.CCWStencilFunc);
|
|
|
|
|
Init.BackFaceStencilFailStencilOp = TranslateStencilOp(Data.CCWStencilFail);
|
|
|
|
|
Init.BackFaceDepthFailStencilOp = TranslateStencilOp(Data.CCWStencilZFail);
|
|
|
|
|
Init.BackFacePassStencilOp = TranslateStencilOp(Data.CCWStencilPass);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FOpenGLBlendState::GetInitializer(FBlendStateInitializerRHI& Init)
|
|
|
|
|
{
|
|
|
|
|
Init.bUseIndependentRenderTargetBlendStates = true;
|
2020-09-24 00:43:27 -04:00
|
|
|
Init.bUseAlphaToCoverage = Data.bUseAlphaToCoverage;
|
2018-05-23 21:04:31 -04:00
|
|
|
for(uint32 RenderTargetIndex = 0;RenderTargetIndex < MaxSimultaneousRenderTargets;++RenderTargetIndex)
|
|
|
|
|
{
|
|
|
|
|
FOpenGLBlendStateData::FRenderTarget const& RenderTarget = Data.RenderTargets[RenderTargetIndex];
|
|
|
|
|
FBlendStateInitializerRHI::FRenderTarget& RenderTargetInitializer = Init.RenderTargets[RenderTargetIndex];
|
|
|
|
|
|
|
|
|
|
RenderTargetInitializer.ColorBlendOp = TranslateBlendOp(RenderTarget.ColorBlendOperation);
|
|
|
|
|
RenderTargetInitializer.ColorSrcBlend = TranslateBlendFactor(RenderTarget.ColorSourceBlendFactor);
|
|
|
|
|
RenderTargetInitializer.ColorDestBlend = TranslateBlendFactor(RenderTarget.ColorDestBlendFactor);
|
|
|
|
|
Init.bUseIndependentRenderTargetBlendStates &= (RenderTargetInitializer.ColorBlendOp == Init.RenderTargets[0].ColorBlendOp);
|
|
|
|
|
Init.bUseIndependentRenderTargetBlendStates &= (RenderTargetInitializer.ColorSrcBlend == Init.RenderTargets[0].ColorSrcBlend);
|
|
|
|
|
Init.bUseIndependentRenderTargetBlendStates &= (RenderTargetInitializer.ColorDestBlend == Init.RenderTargets[0].ColorDestBlend);
|
|
|
|
|
|
|
|
|
|
RenderTargetInitializer.AlphaBlendOp = TranslateBlendOp(RenderTarget.AlphaBlendOperation);
|
|
|
|
|
RenderTargetInitializer.AlphaSrcBlend = TranslateBlendFactor(RenderTarget.AlphaSourceBlendFactor);
|
|
|
|
|
RenderTargetInitializer.AlphaDestBlend = TranslateBlendFactor(RenderTarget.AlphaDestBlendFactor);
|
|
|
|
|
Init.bUseIndependentRenderTargetBlendStates &= (RenderTargetInitializer.AlphaBlendOp == Init.RenderTargets[0].AlphaBlendOp);
|
|
|
|
|
Init.bUseIndependentRenderTargetBlendStates &= (RenderTargetInitializer.AlphaSrcBlend == Init.RenderTargets[0].AlphaSrcBlend);
|
|
|
|
|
Init.bUseIndependentRenderTargetBlendStates &= (RenderTargetInitializer.AlphaDestBlend == Init.RenderTargets[0].AlphaDestBlend);
|
|
|
|
|
|
|
|
|
|
uint32 Mask = CW_NONE;
|
|
|
|
|
Mask |= (RenderTarget.ColorWriteMaskR) ? CW_RED : 0;
|
|
|
|
|
Mask |= (RenderTarget.ColorWriteMaskG) ? CW_GREEN : 0;
|
|
|
|
|
Mask |= (RenderTarget.ColorWriteMaskB) ? CW_BLUE : 0;
|
|
|
|
|
Mask |= (RenderTarget.ColorWriteMaskA) ? CW_ALPHA : 0;
|
|
|
|
|
RenderTargetInitializer.ColorWriteMask = (EColorWriteMask)Mask;
|
|
|
|
|
|
|
|
|
|
Init.bUseIndependentRenderTargetBlendStates &= (RenderTargetInitializer.ColorWriteMask == Init.RenderTargets[0].ColorWriteMask);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
FBlendStateRHIRef FOpenGLDynamicRHI::RHICreateBlendState(const FBlendStateInitializerRHI& Initializer)
|
|
|
|
|
{
|
|
|
|
|
FOpenGLBlendState* BlendState = new FOpenGLBlendState;
|
2020-09-24 00:43:27 -04:00
|
|
|
BlendState->Data.bUseAlphaToCoverage = Initializer.bUseAlphaToCoverage;
|
2014-03-14 14:13:41 -04:00
|
|
|
for(uint32 RenderTargetIndex = 0;RenderTargetIndex < MaxSimultaneousRenderTargets;++RenderTargetIndex)
|
|
|
|
|
{
|
|
|
|
|
const FBlendStateInitializerRHI::FRenderTarget& RenderTargetInitializer =
|
|
|
|
|
Initializer.bUseIndependentRenderTargetBlendStates
|
|
|
|
|
? Initializer.RenderTargets[RenderTargetIndex]
|
|
|
|
|
: Initializer.RenderTargets[0];
|
|
|
|
|
FOpenGLBlendStateData::FRenderTarget& RenderTarget = BlendState->Data.RenderTargets[RenderTargetIndex];
|
|
|
|
|
RenderTarget.bAlphaBlendEnable =
|
|
|
|
|
RenderTargetInitializer.ColorBlendOp != BO_Add || RenderTargetInitializer.ColorDestBlend != BF_Zero || RenderTargetInitializer.ColorSrcBlend != BF_One ||
|
|
|
|
|
RenderTargetInitializer.AlphaBlendOp != BO_Add || RenderTargetInitializer.AlphaDestBlend != BF_Zero || RenderTargetInitializer.AlphaSrcBlend != BF_One;
|
|
|
|
|
RenderTarget.ColorBlendOperation = TranslateBlendOp(RenderTargetInitializer.ColorBlendOp);
|
|
|
|
|
RenderTarget.ColorSourceBlendFactor = TranslateBlendFactor(RenderTargetInitializer.ColorSrcBlend);
|
|
|
|
|
RenderTarget.ColorDestBlendFactor = TranslateBlendFactor(RenderTargetInitializer.ColorDestBlend);
|
|
|
|
|
RenderTarget.bSeparateAlphaBlendEnable =
|
|
|
|
|
RenderTargetInitializer.AlphaDestBlend != RenderTargetInitializer.ColorDestBlend ||
|
|
|
|
|
RenderTargetInitializer.AlphaSrcBlend != RenderTargetInitializer.ColorSrcBlend;
|
|
|
|
|
RenderTarget.AlphaBlendOperation = TranslateBlendOp(RenderTargetInitializer.AlphaBlendOp);
|
|
|
|
|
RenderTarget.AlphaSourceBlendFactor = TranslateBlendFactor(RenderTargetInitializer.AlphaSrcBlend);
|
|
|
|
|
RenderTarget.AlphaDestBlendFactor = TranslateBlendFactor(RenderTargetInitializer.AlphaDestBlend);
|
|
|
|
|
RenderTarget.ColorWriteMaskR = (RenderTargetInitializer.ColorWriteMask & CW_RED) != 0;
|
|
|
|
|
RenderTarget.ColorWriteMaskG = (RenderTargetInitializer.ColorWriteMask & CW_GREEN) != 0;
|
|
|
|
|
RenderTarget.ColorWriteMaskB = (RenderTargetInitializer.ColorWriteMask & CW_BLUE) != 0;
|
|
|
|
|
RenderTarget.ColorWriteMaskA = (RenderTargetInitializer.ColorWriteMask & CW_ALPHA) != 0;
|
|
|
|
|
}
|
2015-02-25 08:13:48 -05:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
return BlendState;
|
|
|
|
|
}
|
2015-06-18 13:23:31 -04:00
|
|
|
|
|
|
|
|
//!AB: moved from the header, since it was causing linker error when the header is included externally
|
|
|
|
|
void FOpenGLRHIState::InitializeResources(int32 NumCombinedTextures, int32 NumComputeUAVUnits)
|
|
|
|
|
{
|
|
|
|
|
check(!ShaderParameters);
|
|
|
|
|
FOpenGLCommonState::InitializeResources(NumCombinedTextures, NumComputeUAVUnits);
|
|
|
|
|
ShaderParameters = new FOpenGLShaderParameterCache[CrossCompiler::NUM_SHADER_STAGES];
|
|
|
|
|
ShaderParameters[CrossCompiler::SHADER_STAGE_VERTEX].InitializeResources(FOpenGL::GetMaxVertexUniformComponents() * 4 * sizeof(float));
|
|
|
|
|
ShaderParameters[CrossCompiler::SHADER_STAGE_PIXEL].InitializeResources(FOpenGL::GetMaxPixelUniformComponents() * 4 * sizeof(float));
|
|
|
|
|
ShaderParameters[CrossCompiler::SHADER_STAGE_GEOMETRY].InitializeResources(FOpenGL::GetMaxGeometryUniformComponents() * 4 * sizeof(float));
|
|
|
|
|
|
2018-05-23 21:04:31 -04:00
|
|
|
LinkedProgramAndDirtyFlag = nullptr;
|
2021-02-16 00:46:28 -04:00
|
|
|
ShaderParameters[CrossCompiler::SHADER_STAGE_COMPUTE].InitializeResources(FOpenGL::GetMaxComputeUniformComponents() * 4 * sizeof(float));
|
2015-06-18 13:23:31 -04:00
|
|
|
|
2019-01-28 09:49:53 -05:00
|
|
|
for (int32 Frequency = 0; Frequency < SF_NumStandardFrequencies; ++Frequency)
|
2015-06-18 13:23:31 -04:00
|
|
|
{
|
|
|
|
|
DirtyUniformBuffers[Frequency] = MAX_uint16;
|
2022-04-26 04:22:05 -04:00
|
|
|
bAnyDirtyRealUniformBuffers[Frequency] = true;
|
2015-06-18 13:23:31 -04:00
|
|
|
}
|
2018-05-23 21:04:31 -04:00
|
|
|
bAnyDirtyGraphicsUniformBuffers = true;
|
2015-06-18 13:23:31 -04:00
|
|
|
}
|