Files
UnrealEngineUWP/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLUAV.cpp

394 lines
13 KiB
C++
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
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 "RenderUtils.h"
#include "OpenGLDrv.h"
#include "OpenGLDrvPrivate.h"
#include "ClearReplacementShaders.h"
// Binds the specified buffer range to a texture resource and selects glTexBuffer or glTexBufferRange
static void BindGLTexBufferRange(GLenum Target, GLenum InternalFormat, GLuint Buffer, uint32 StartOffsetBytes, uint32 NumElements, uint32 Stride)
{
if (StartOffsetBytes == 0 && NumElements == UINT32_MAX)
{
FOpenGL::TexBuffer(Target, InternalFormat, Buffer);
}
else
{
// Validate buffer offset is a multiple of buffer offset alignment
GLintptr Offset = StartOffsetBytes;
GLsizeiptr Size = NumElements * Stride;
#if DO_CHECK
GLint Alignment = FOpenGLBase::GetTextureBufferAlignment();
check(Stride > 0 && Offset % Alignment == 0);
#endif
FOpenGL::TexBufferRange(Target, InternalFormat, Buffer, Offset, Size);
}
}
FOpenGLShaderResourceView::FOpenGLShaderResourceView(const FShaderResourceViewInitializer& Initializer)
Added RHI tracked access API to remove Unknown transitions. - New RHI command list SetTrackedAccess method for the user to supply a current whole-resource state. - New RHI command context GetTrackedAccess method for querying the tracked access in RHIBeginTransitions / RHIEndTransitions on the RHI thread. - Hooked RHICmdList.Transition and FRHICommandListExecutor::Transition to assign tracked state automatically. - Refactored RDG and resource pools to use new RHI tracking. - FRDGPooledBuffer / FRDGPooledTexture no longer contain tracked state. RDG temp-allocates state through the graph allocator instead. - All prologue transitions are 'Unknown', and all epilogue transitions coalesce into a whole resource state. - Implemented platform support for patching the 'before' state with the tracked state. - Implemented various RHI validation checks: - Asserts that the user assigned tracked state matches RHI validation tracked state, for all subresources. - Asserts that tracked state is not assigned or queried from a parallel translation context. - Added FRHIViewableResource and FRHIView base classes to RHI. FRHIView contains a pointer to an FRHIViewableResource. This is currently a raw pointer, but should be extended to a full reference in a later CL. NOTE on RHI thread constraint: Transition evaluation is now restricted to the RHI thread (i.e. no parallel translation contexts). Transitions aren't performed in parallel translate contexts anyway, so this is not a problem. If, however, we decide to refactor parallel translation to be more general, this implementation could be extended to track the state per context and update from the 'dispatch' thread. #preflight 6233b4396666d7e753a16aaf #rb kenzo.terelst [CL 19513316 by zach bethel in ue5-main branch]
2022-03-25 11:19:10 -04:00
: FRHIShaderResourceView(Initializer.AsBufferSRV().Buffer)
{
FShaderResourceViewInitializer::FBufferShaderResourceViewInitializer Desc = Initializer.AsBufferSRV();
Buffer = FOpenGLDynamicRHI::ResourceCast(Desc.Buffer);
if (Buffer == nullptr)
{
return;
}
EPixelFormat Format = Desc.Format;
if (Initializer.GetType() == FShaderResourceViewInitializer::EType::IndexBufferSRV && Format == PF_Unknown)
{
uint32 Stride = Buffer->GetStride();
Format = (Stride == 2) ? PF_R16_UINT : PF_R32_UINT;
}
if (Format != PF_Unknown)
{
Target = GL_TEXTURE_BUFFER;
OwnsResource = true;
UE_CLOG(!GPixelFormats[Format].Supported, LogRHI, Error, TEXT("Unsupported EPixelFormat %d"), Format);
RunOnGLRenderContextThread([this, Format, StartOffsetBytes = Desc.StartOffsetBytes, NumElements = Desc.NumElements]()
{
FOpenGL::GenTextures(1, &Resource);
// Use a texture stage that's not likely to be used for draws, to avoid waiting
FOpenGLDynamicRHI::Get().CachedSetupTextureStage(
FOpenGLDynamicRHI::Get().GetContextStateForCurrentContext(),
FOpenGL::GetMaxCombinedTextureImageUnits() - 1,
GL_TEXTURE_BUFFER,
Resource,
-1,
1
);
BindGLTexBufferRange(
GL_TEXTURE_BUFFER,
GOpenGLTextureFormats[Format].InternalFormat[0],
Buffer->Resource,
StartOffsetBytes,
NumElements,
GPixelFormats[Format].BlockBytes
);
});
}
else
{
//TODO: add range views for SSBO
ensure(Desc.IsWholeResource());
Target = GL_SHADER_STORAGE_BUFFER;
RunOnGLRenderContextThread([this]()
{
Resource = Buffer->Resource;
});
}
}
FShaderResourceViewRHIRef FOpenGLDynamicRHI::RHICreateShaderResourceView(const FShaderResourceViewInitializer& Initializer)
{
return new FOpenGLShaderResourceView(Initializer);
}
FShaderResourceViewRHIRef FOpenGLDynamicRHI::RHICreateShaderResourceView(FRHIBuffer* BufferRHI, uint32 Stride, uint8 Format)
{
ensureMsgf(Stride == GPixelFormats[Format].BlockBytes, TEXT("provided stride: %i was not consitent with Pixelformat: %s"), Stride, GPixelFormats[Format].Name);
return FOpenGLDynamicRHI::RHICreateShaderResourceView(FShaderResourceViewInitializer(BufferRHI, EPixelFormat(Format)));
}
FShaderResourceViewRHIRef FOpenGLDynamicRHI::RHICreateShaderResourceView(FRHIBuffer* BufferRHI)
{
return FOpenGLDynamicRHI::RHICreateShaderResourceView(FShaderResourceViewInitializer(BufferRHI));
}
void FOpenGLDynamicRHI::RHIUpdateShaderResourceView(FRHIShaderResourceView* SRV, FRHIBuffer* InBuffer)
{
VERIFY_GL_SCOPE();
FOpenGLShaderResourceView* SRVGL = FOpenGLDynamicRHI::ResourceCast(SRV);
FOpenGLBuffer* BufferGL = FOpenGLDynamicRHI::ResourceCast(InBuffer);
check(SRVGL);
if (SRVGL->Target == GL_TEXTURE_BUFFER)
{
GLuint TextureID = SRVGL->Resource;
CachedSetupTextureStage(GetContextStateForCurrentContext(), FOpenGL::GetMaxCombinedTextureImageUnits() - 1, GL_TEXTURE_BUFFER, TextureID, -1, 1);
if (!BufferGL)
{
FOpenGL::TexBuffer(GL_TEXTURE_BUFFER, GL_R16UI, 0); // format ignored here since we're detaching.
SRVGL->Buffer = nullptr;
}
else
{
uint32 Stride = BufferGL->GetStride();
GLenum Format = (Stride == 2) ? GL_R16UI : GL_R32UI;
uint32 NumElements = BufferGL->GetSize() / Stride;
BindGLTexBufferRange(GL_TEXTURE_BUFFER, Format, BufferGL->Resource, 0, NumElements, Stride);
SRVGL->Buffer = BufferGL;
}
}
else if (SRVGL->Target == GL_SHADER_STORAGE_BUFFER)
{
SRVGL->Resource = BufferGL->Resource;
SRVGL->Buffer = BufferGL;
}
else
{
checkNoEntry();
}
}
void FOpenGLDynamicRHI::RHIUpdateShaderResourceView(FRHIShaderResourceView* SRV, FRHIBuffer* InBuffer, uint32 Stride, uint8 Format)
{
VERIFY_GL_SCOPE();
FOpenGLShaderResourceView* SRVGL = FOpenGLDynamicRHI::ResourceCast(SRV);
FOpenGLBuffer* BufferGL = FOpenGLDynamicRHI::ResourceCast(InBuffer);
const FOpenGLTextureFormat& GLFormat = GOpenGLTextureFormats[Format];
check(SRVGL);
check(SRVGL->Target == GL_TEXTURE_BUFFER); // add support for SSBO views?
GLuint TextureID = SRVGL->Resource;
CachedSetupTextureStage(GetContextStateForCurrentContext(), FOpenGL::GetMaxCombinedTextureImageUnits() - 1, GL_TEXTURE_BUFFER, TextureID, -1, 1);
if (!BufferGL)
{
FOpenGL::TexBuffer(GL_TEXTURE_BUFFER, GLFormat.InternalFormat[0], 0);
SRVGL->Buffer = nullptr;
}
else
{
FOpenGL::TexBuffer(GL_TEXTURE_BUFFER, GLFormat.InternalFormat[0], BufferGL->Resource);
SRVGL->Buffer = BufferGL;
}
}
FOpenGLShaderResourceView::~FOpenGLShaderResourceView()
{
if (Resource && OwnsResource)
{
RunOnGLRenderContextThread([Resource = Resource]()
{
VERIFY_GL_SCOPE();
FOpenGLDynamicRHI::Get().InvalidateTextureResourceInCache(Resource);
FOpenGL::DeleteTextures(1, &Resource);
});
}
}
FUnorderedAccessViewRHIRef FOpenGLDynamicRHI::RHICreateUnorderedAccessView(FRHITexture* TextureRHI, uint32 MipLevel, uint16 FirstArraySlice, uint16 NumArraySlices)
{
check(TextureRHI->GetFlags() & TexCreate_UAV);
// Slice selection of a texture array still need to be implemented on OpenGL
check(FirstArraySlice == 0 && NumArraySlices == 0);
return new FOpenGLTextureUnorderedAccessView(TextureRHI);
}
FOpenGLTextureUnorderedAccessView::FOpenGLTextureUnorderedAccessView(FRHITexture* InTextureRHI):
Added RHI tracked access API to remove Unknown transitions. - New RHI command list SetTrackedAccess method for the user to supply a current whole-resource state. - New RHI command context GetTrackedAccess method for querying the tracked access in RHIBeginTransitions / RHIEndTransitions on the RHI thread. - Hooked RHICmdList.Transition and FRHICommandListExecutor::Transition to assign tracked state automatically. - Refactored RDG and resource pools to use new RHI tracking. - FRDGPooledBuffer / FRDGPooledTexture no longer contain tracked state. RDG temp-allocates state through the graph allocator instead. - All prologue transitions are 'Unknown', and all epilogue transitions coalesce into a whole resource state. - Implemented platform support for patching the 'before' state with the tracked state. - Implemented various RHI validation checks: - Asserts that the user assigned tracked state matches RHI validation tracked state, for all subresources. - Asserts that tracked state is not assigned or queried from a parallel translation context. - Added FRHIViewableResource and FRHIView base classes to RHI. FRHIView contains a pointer to an FRHIViewableResource. This is currently a raw pointer, but should be extended to a full reference in a later CL. NOTE on RHI thread constraint: Transition evaluation is now restricted to the RHI thread (i.e. no parallel translation contexts). Transitions aren't performed in parallel translate contexts anyway, so this is not a problem. If, however, we decide to refactor parallel translation to be more general, this implementation could be extended to track the state per context and update from the 'dispatch' thread. #preflight 6233b4396666d7e753a16aaf #rb kenzo.terelst [CL 19513316 by zach bethel in ue5-main branch]
2022-03-25 11:19:10 -04:00
FOpenGLUnorderedAccessView(InTextureRHI),
TextureRHI(InTextureRHI)
{
VERIFY_GL_SCOPE();
FOpenGLTexture* Texture = GetOpenGLTextureFromRHITexture(TextureRHI);
const FOpenGLTextureFormat& GLFormat = GOpenGLTextureFormats[TextureRHI->GetFormat()];
check(!Texture->CanBeEvicted() && !Texture->IsEvicted());
this->Resource = Texture->GetResource();
this->Format = GLFormat.InternalFormat[0];
this->UnrealFormat = TextureRHI->GetFormat();
this->bLayered = (Texture->Target == GL_TEXTURE_3D);
}
FUnorderedAccessViewRHIRef FOpenGLDynamicRHI::RHICreateUnorderedAccessView(FRHIBuffer* BufferRHI, uint8 Format)
{
check(BufferRHI->GetUsage() & BUF_UnorderedAccess);
return new FOpenGLTexBufferUnorderedAccessView(this, BufferRHI, Format);
}
FOpenGLTexBufferUnorderedAccessView::FOpenGLTexBufferUnorderedAccessView(FOpenGLDynamicRHI* InOpenGLRHI, FRHIBuffer* InBufferRHI, uint8 Format):
Added RHI tracked access API to remove Unknown transitions. - New RHI command list SetTrackedAccess method for the user to supply a current whole-resource state. - New RHI command context GetTrackedAccess method for querying the tracked access in RHIBeginTransitions / RHIEndTransitions on the RHI thread. - Hooked RHICmdList.Transition and FRHICommandListExecutor::Transition to assign tracked state automatically. - Refactored RDG and resource pools to use new RHI tracking. - FRDGPooledBuffer / FRDGPooledTexture no longer contain tracked state. RDG temp-allocates state through the graph allocator instead. - All prologue transitions are 'Unknown', and all epilogue transitions coalesce into a whole resource state. - Implemented platform support for patching the 'before' state with the tracked state. - Implemented various RHI validation checks: - Asserts that the user assigned tracked state matches RHI validation tracked state, for all subresources. - Asserts that tracked state is not assigned or queried from a parallel translation context. - Added FRHIViewableResource and FRHIView base classes to RHI. FRHIView contains a pointer to an FRHIViewableResource. This is currently a raw pointer, but should be extended to a full reference in a later CL. NOTE on RHI thread constraint: Transition evaluation is now restricted to the RHI thread (i.e. no parallel translation contexts). Transitions aren't performed in parallel translate contexts anyway, so this is not a problem. If, however, we decide to refactor parallel translation to be more general, this implementation could be extended to track the state per context and update from the 'dispatch' thread. #preflight 6233b4396666d7e753a16aaf #rb kenzo.terelst [CL 19513316 by zach bethel in ue5-main branch]
2022-03-25 11:19:10 -04:00
FOpenGLUnorderedAccessView(InBufferRHI),
BufferRHI(InBufferRHI),
OpenGLRHI(InOpenGLRHI)
{
VERIFY_GL_SCOPE();
FOpenGLBuffer* InBuffer = FOpenGLDynamicRHI::ResourceCast(InBufferRHI);
const FOpenGLTextureFormat& GLFormat = GOpenGLTextureFormats[Format];
GLuint TextureID = 0;
FOpenGL::GenTextures(1, &TextureID);
// Use a texture stage that's not likely to be used for draws, to avoid waiting
OpenGLRHI->CachedSetupTextureStage(OpenGLRHI->GetContextStateForCurrentContext(), FOpenGL::GetMaxCombinedTextureImageUnits() - 1, GL_TEXTURE_BUFFER, TextureID, -1, 1);
FOpenGL::TexBuffer(GL_TEXTURE_BUFFER, GLFormat.InternalFormat[0], InBuffer->Resource);
// No need to restore texture stage; leave it like this,
// and the next draw will take care of cleaning it up; or
// next operation that needs the stage will switch something else in on it.
this->Resource = TextureID;
this->BufferResource = InBuffer->Resource;
this->Format = GLFormat.InternalFormat[0];
this->UnrealFormat = Format;
}
uint32 FOpenGLTexBufferUnorderedAccessView::GetBufferSize()
Copying //UE4/Dev-Mobile to //UE4/Dev-Main (Source: //UE4/Dev-Mobile @ 3116515) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3065209 on 2016/07/26 by Steve.Cano Add Android Texture Format used for packaging/cooking to the Manifest File #ue4 #android #jira UE-33645 Change 3068915 on 2016/07/28 by Steve.Cano Add an additional Texture Compression support line in the manifest for DXT #ue4 #android #jira UE-33645 Change 3075911 on 2016/08/03 by Steve.Cano Make the "Running {ProjectName} on {Device}" toast stay up when launching a game to an Android device until we've finished running it, as it does on other platforms. This logic already existed but only ran if the "Prebuilt" flag was passed in, however we want this to always run now. Re-writing to run through waiting on each process to finish for each device launched on #jira UE-3122 #ue4 #android Change 3080981 on 2016/08/08 by Steve.Cano Clear any input before removing the TouchInterface from the screen to prevent infinite input after it is cleared #jira UE-33956 #ue4 #platform Change 3092587 on 2016/08/17 by Steve.Cano Adding "IsGamepadAttached" functionality to Android Application #jira UE-33264 #ue4 #android Change 3095840 on 2016/08/21 by Dmitriy.Dyomin Fixed: Particle Cutout Crashes On Certain Devices (Samsung Galaxy Note 2) Happens only with non-instanced path #jira UE-34604 Change 3095855 on 2016/08/22 by Dmitriy.Dyomin Allow UWorldComposition::GetTilesList to be used in runtime code Licensee request https://udn.unrealengine.com/questions/307586/world-compositions-world-dimensions.html Change 3096093 on 2016/08/22 by Allan.Bentham Allow Vulkan api logging on android Change 3096361 on 2016/08/22 by Steve.Cano Github 2663 pull - Pass any extras used to launch SplashActivity down to GameActivity (Contributed by sangpan) #jira UE-34050 #github #2663 #ue4 #android Change 3097412 on 2016/08/23 by Dmitriy.Dyomin Using BulkSerialize for cooked collision data to speed up serialization Change 3098957 on 2016/08/23 by Jack.Porter Merging //UE4/Dev-Main to Dev-Mobile (//UE4/Dev-Mobile) Change 3099058 on 2016/08/24 by Jack.Porter Check EXT_debug_label and EXT_debug_marker functions were found before calling as a few devices to not implement these extensions #UE-35087 Change 3099131 on 2016/08/24 by Dmitriy.Dyomin Fixed: HDR compressed texture become black in some mali devices Use sized internal format for half-float textures on ES3 devices, as ES3 spec expects it #jira UE-35018 Change 3099150 on 2016/08/24 by Dmitriy.Dyomin Enable HALF_FLOAT and UNSIGNED_INT_2_10_10_10_REV vertex formats on ES3+ devices, spec req Change 3102252 on 2016/08/26 by Dmitriy.Dyomin Prevent view uniform buffer crash on ES2 devices that do not support 3D textures Change 3102258 on 2016/08/26 by Dmitriy.Dyomin Enabled refraction on iPadMini4 #jira UE-35079 Change 3102651 on 2016/08/26 by Dmitriy.Dyomin Fixed: instanced static mesh world normals Also removed unnecessary instance matrix transposing #jira UE-35075 Change 3109397 on 2016/09/01 by Jack.Porter Fix problem with Android sessions not appearing in Session Frontend #jira UE-35261 Change 3109490 on 2016/09/01 by Jack.Porter Merging //UE4/Dev-Main to Dev-Mobile (//UE4/Dev-Mobile) Change 3111628 on 2016/09/02 by Jack.Porter Landscape wireframe LOD visualization with tessellation Change 3112809 on 2016/09/02 by Chris.Babcock Update cached length when file is written to on Android #jira UE-35558 #ue4 #android Change 3113245 on 2016/09/04 by Dmitriy.Dyomin Fixed: Subway Sequencer plays only a black screen when packaged for ESDSR (3.1+AEP) #jira UE-34291 Change 3113249 on 2016/09/04 by Dmitriy.Dyomin Replicated fix from 4.13: GPU particles no longer work on iOS or TVOS Metal devices #jira UE-34782 Change 3113513 on 2016/09/05 by Allan.Bentham Add vulkan version parameter to android device profile selector's source inputs . reinstate Vulkan Disable cvar functionality. Added mali no vulkan device profile. Change 3113519 on 2016/09/05 by Allan.Bentham Remove temp 4.13 hack to avoid public header changes. Change 3113535 on 2016/09/05 by Allan.Bentham Decode 32 bit HDR formats when using scene captures. #jira UE-25444 Change 3113813 on 2016/09/06 by Dmitriy.Dyomin Resend to server sub-levels visibility state right after world actors are initialized. During seamless travel client loads always-loaded sub-levels before world actors are initialized and ServerUpdateLevelVisibility calls in UWorld::AddToWorld are skipped. Change 3113870 on 2016/09/06 by Jack.Porter Fix issue with ES2 Feature Level preview and Mobile Preview PIE not limiting materials to 8 textures #jira UE-35591 Change 3115031 on 2016/09/06 by Chris.Babcock Add Vulkan version code not moved over from 4.13.1 #jira UE-35642 #ue4 #android Change 3115496 on 2016/09/07 by Dmitriy.Dyomin Use the same DDC key for source reflection data and encoded data. Fixes broken reflections on mobile #jira UE-35647 [CL 3116720 by Chris Babcock in Main branch]
2016-09-07 17:04:11 -04:00
{
return BufferRHI->GetSize();
Copying //UE4/Dev-Mobile to //UE4/Dev-Main (Source: //UE4/Dev-Mobile @ 3116515) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3065209 on 2016/07/26 by Steve.Cano Add Android Texture Format used for packaging/cooking to the Manifest File #ue4 #android #jira UE-33645 Change 3068915 on 2016/07/28 by Steve.Cano Add an additional Texture Compression support line in the manifest for DXT #ue4 #android #jira UE-33645 Change 3075911 on 2016/08/03 by Steve.Cano Make the "Running {ProjectName} on {Device}" toast stay up when launching a game to an Android device until we've finished running it, as it does on other platforms. This logic already existed but only ran if the "Prebuilt" flag was passed in, however we want this to always run now. Re-writing to run through waiting on each process to finish for each device launched on #jira UE-3122 #ue4 #android Change 3080981 on 2016/08/08 by Steve.Cano Clear any input before removing the TouchInterface from the screen to prevent infinite input after it is cleared #jira UE-33956 #ue4 #platform Change 3092587 on 2016/08/17 by Steve.Cano Adding "IsGamepadAttached" functionality to Android Application #jira UE-33264 #ue4 #android Change 3095840 on 2016/08/21 by Dmitriy.Dyomin Fixed: Particle Cutout Crashes On Certain Devices (Samsung Galaxy Note 2) Happens only with non-instanced path #jira UE-34604 Change 3095855 on 2016/08/22 by Dmitriy.Dyomin Allow UWorldComposition::GetTilesList to be used in runtime code Licensee request https://udn.unrealengine.com/questions/307586/world-compositions-world-dimensions.html Change 3096093 on 2016/08/22 by Allan.Bentham Allow Vulkan api logging on android Change 3096361 on 2016/08/22 by Steve.Cano Github 2663 pull - Pass any extras used to launch SplashActivity down to GameActivity (Contributed by sangpan) #jira UE-34050 #github #2663 #ue4 #android Change 3097412 on 2016/08/23 by Dmitriy.Dyomin Using BulkSerialize for cooked collision data to speed up serialization Change 3098957 on 2016/08/23 by Jack.Porter Merging //UE4/Dev-Main to Dev-Mobile (//UE4/Dev-Mobile) Change 3099058 on 2016/08/24 by Jack.Porter Check EXT_debug_label and EXT_debug_marker functions were found before calling as a few devices to not implement these extensions #UE-35087 Change 3099131 on 2016/08/24 by Dmitriy.Dyomin Fixed: HDR compressed texture become black in some mali devices Use sized internal format for half-float textures on ES3 devices, as ES3 spec expects it #jira UE-35018 Change 3099150 on 2016/08/24 by Dmitriy.Dyomin Enable HALF_FLOAT and UNSIGNED_INT_2_10_10_10_REV vertex formats on ES3+ devices, spec req Change 3102252 on 2016/08/26 by Dmitriy.Dyomin Prevent view uniform buffer crash on ES2 devices that do not support 3D textures Change 3102258 on 2016/08/26 by Dmitriy.Dyomin Enabled refraction on iPadMini4 #jira UE-35079 Change 3102651 on 2016/08/26 by Dmitriy.Dyomin Fixed: instanced static mesh world normals Also removed unnecessary instance matrix transposing #jira UE-35075 Change 3109397 on 2016/09/01 by Jack.Porter Fix problem with Android sessions not appearing in Session Frontend #jira UE-35261 Change 3109490 on 2016/09/01 by Jack.Porter Merging //UE4/Dev-Main to Dev-Mobile (//UE4/Dev-Mobile) Change 3111628 on 2016/09/02 by Jack.Porter Landscape wireframe LOD visualization with tessellation Change 3112809 on 2016/09/02 by Chris.Babcock Update cached length when file is written to on Android #jira UE-35558 #ue4 #android Change 3113245 on 2016/09/04 by Dmitriy.Dyomin Fixed: Subway Sequencer plays only a black screen when packaged for ESDSR (3.1+AEP) #jira UE-34291 Change 3113249 on 2016/09/04 by Dmitriy.Dyomin Replicated fix from 4.13: GPU particles no longer work on iOS or TVOS Metal devices #jira UE-34782 Change 3113513 on 2016/09/05 by Allan.Bentham Add vulkan version parameter to android device profile selector's source inputs . reinstate Vulkan Disable cvar functionality. Added mali no vulkan device profile. Change 3113519 on 2016/09/05 by Allan.Bentham Remove temp 4.13 hack to avoid public header changes. Change 3113535 on 2016/09/05 by Allan.Bentham Decode 32 bit HDR formats when using scene captures. #jira UE-25444 Change 3113813 on 2016/09/06 by Dmitriy.Dyomin Resend to server sub-levels visibility state right after world actors are initialized. During seamless travel client loads always-loaded sub-levels before world actors are initialized and ServerUpdateLevelVisibility calls in UWorld::AddToWorld are skipped. Change 3113870 on 2016/09/06 by Jack.Porter Fix issue with ES2 Feature Level preview and Mobile Preview PIE not limiting materials to 8 textures #jira UE-35591 Change 3115031 on 2016/09/06 by Chris.Babcock Add Vulkan version code not moved over from 4.13.1 #jira UE-35642 #ue4 #android Change 3115496 on 2016/09/07 by Dmitriy.Dyomin Use the same DDC key for source reflection data and encoded data. Fixes broken reflections on mobile #jira UE-35647 [CL 3116720 by Chris Babcock in Main branch]
2016-09-07 17:04:11 -04:00
}
FOpenGLTexBufferUnorderedAccessView::~FOpenGLTexBufferUnorderedAccessView()
{
if (Resource)
{
RunOnGLRenderContextThread([OpenGLRHI= OpenGLRHI, Resource = Resource]()
{
VERIFY_GL_SCOPE();
OpenGLRHI->InvalidateTextureResourceInCache(Resource);
FOpenGL::DeleteTextures(1, &Resource);
});
}
}
FUnorderedAccessViewRHIRef FOpenGLDynamicRHI::RHICreateUnorderedAccessView(FRHIBuffer* BufferRHI, bool bUseUAVCounter, bool bAppendBuffer)
{
check(BufferRHI->GetUsage() & BUF_UnorderedAccess);
return new FOpenGLBufferUnorderedAccessView(this, BufferRHI);
}
FOpenGLBufferUnorderedAccessView::FOpenGLBufferUnorderedAccessView(FOpenGLDynamicRHI* InOpenGLRHI, FRHIBuffer* InBufferRHI)
Added RHI tracked access API to remove Unknown transitions. - New RHI command list SetTrackedAccess method for the user to supply a current whole-resource state. - New RHI command context GetTrackedAccess method for querying the tracked access in RHIBeginTransitions / RHIEndTransitions on the RHI thread. - Hooked RHICmdList.Transition and FRHICommandListExecutor::Transition to assign tracked state automatically. - Refactored RDG and resource pools to use new RHI tracking. - FRDGPooledBuffer / FRDGPooledTexture no longer contain tracked state. RDG temp-allocates state through the graph allocator instead. - All prologue transitions are 'Unknown', and all epilogue transitions coalesce into a whole resource state. - Implemented platform support for patching the 'before' state with the tracked state. - Implemented various RHI validation checks: - Asserts that the user assigned tracked state matches RHI validation tracked state, for all subresources. - Asserts that tracked state is not assigned or queried from a parallel translation context. - Added FRHIViewableResource and FRHIView base classes to RHI. FRHIView contains a pointer to an FRHIViewableResource. This is currently a raw pointer, but should be extended to a full reference in a later CL. NOTE on RHI thread constraint: Transition evaluation is now restricted to the RHI thread (i.e. no parallel translation contexts). Transitions aren't performed in parallel translate contexts anyway, so this is not a problem. If, however, we decide to refactor parallel translation to be more general, this implementation could be extended to track the state per context and update from the 'dispatch' thread. #preflight 6233b4396666d7e753a16aaf #rb kenzo.terelst [CL 19513316 by zach bethel in ue5-main branch]
2022-03-25 11:19:10 -04:00
: FOpenGLUnorderedAccessView(InBufferRHI)
, BufferRHI(InBufferRHI)
, OpenGLRHI(InOpenGLRHI)
{
VERIFY_GL_SCOPE();
FOpenGLBuffer* Buffer = FOpenGLDynamicRHI::ResourceCast(BufferRHI.GetReference());
this->BufferResource = Buffer->Resource;
}
uint32 FOpenGLBufferUnorderedAccessView::GetBufferSize()
{
return BufferRHI->GetSize();
}
FOpenGLBufferUnorderedAccessView::~FOpenGLBufferUnorderedAccessView()
{
// not clearing cached state as SSBO can still be bound as SRV
}
void FOpenGLDynamicRHI::RHIClearUAVFloat(FRHIUnorderedAccessView* UnorderedAccessViewRHI, const FVector4f& Values)
{
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3109293) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3091951 on 2016/08/17 by Chris.Bunner (Duplicate) CL 3090919: Fixed edge case interactions in HLOD ray rejection logic in Lightmass. Change 3093162 on 2016/08/18 by Ben.Woodhouse Fix minor memory leak (missing delete of RT Heartbeat thread) Change 3093470 on 2016/08/18 by Ben.Woodhouse Fix minor leak in FMonitoredProcess - the Thread member would get leaked if the FMonitoredProcess was cancelled, because it gets NULLed without deleting it. Fix is to add a bool to keep track of whether the thread is running, rather than using the Thread pointer. Also fixes a race condition where the FMonitoredProcess::Thread member could get initialized after the thread had completed. This would cause IsRunning to never return false, even if the thread has completed, and the editor would hang on startup (this was fixed by setting bIsRunning to true before creating the thread) Change 3093698 on 2016/08/18 by Daniel.Wright Translucent lighting volume draw event cleanup Change 3093700 on 2016/08/18 by Daniel.Wright Clamp on box reflection capture transition distance visualizer Change 3093755 on 2016/08/18 by Ryan.Vance Merging stereo planar reflections from Odin. Change 3094060 on 2016/08/18 by Daniel.Wright Fully featured base pass reflection captures with blending and parallax correction * Used in the forward renderer when materials opt-in to 'High Quality Reflections' * Used in the deferred renderer for translucent 'Surface ForwardShading' materials * Reflection captures are culled to a frustum space grid using the same reverse linked-list method as lights in the forward renderer * Fixed grid culling in stereo / splitscreen * The ReflectionEnvironment compute shader used in the deferred path also uses the culled grid now which reduces its cost from .93ms -> .70ms on 970 GTX. PS4 cost is about the same. * Capsule indirect self-shadowing is now reduced in the forward path to match deferred, and both are controlled by r.CapsuleIndirectShadowSelfShadowIntensity * SetupHZB is now skipped when SSAO / SSR / HZB are all disabled Change 3094160 on 2016/08/18 by Daniel.Wright CIS fixes Change 3094899 on 2016/08/19 by Ben.Woodhouse Batching optimization for dragging components onto blueprints, reported on UDN. Adding 2300 static mesh actors now takes 3 seconds instead of 40 minutes. https://udn.unrealengine.com/questions/305821/suspected-rhi-uniform-buffer-leak-when-adding-stat.html #jira UE-34937 Change 3095256 on 2016/08/19 by Daniel.Wright Disabled ISR warning spamming CIS Change 3095468 on 2016/08/19 by Daniel.Wright Fixed refcounting on hit proxy render targets Change 3095470 on 2016/08/19 by Daniel.Wright Added bVisibleInReflectionCaptures to primitive component, which is useful for hiding objects too close to the capture point Change 3096274 on 2016/08/22 by Rolando.Caloca DR - vk - added missing BC4 Change 3096291 on 2016/08/22 by Rolando.Caloca DR - vk - Fix image views for some rendertarget formats - Fix ImageViews on sub mips Change 3096579 on 2016/08/22 by Rolando.Caloca DR - vk - Fix rendering for shaders with no descriptors Change 3096584 on 2016/08/22 by Rolando.Caloca DR - vk - Fix 3d texture update Change 3096813 on 2016/08/22 by Rolando.Caloca DR - Fix GL linking errors PR #2615 Change 3097062 on 2016/08/22 by Rolando.Caloca DR - vk - Added unified mem flag - Added Mip index into UAV - Switched compute descriptor set index 0 Change 3097065 on 2016/08/22 by Rolando.Caloca DR - vk - Framebuffer barriers now wait on STAGE_FRAGMENT_SHADER instead of STAGE_BOTTOM_OF_PIPE Change 3097084 on 2016/08/22 by Daniel.Wright Enabled r.VertexFoggingForOpaque by default to match other forward renderer choices (fast by default) Change 3097086 on 2016/08/22 by Rolando.Caloca DR - vk - Missed file Change 3097943 on 2016/08/23 by Rolando.Caloca DR - hlslcc - Remove duplicated definitions out into a common header Change 3098166 on 2016/08/23 by Rolando.Caloca DR - Custom Renderer callback after getting SceneColor Change 3098418 on 2016/08/23 by Olaf.Piesche Moving vertex factory dirtying to always happen in-editor for mesh emitters on dynamic data reinitialization; there are several cases in which this needs to happen (some material changes, mesh reimports...) which are difficult to track, so in-editor we just always recreate the mesh particle vertex factory with the dynamic data. #jira UE-34838 Change 3098448 on 2016/08/23 by Rolando.Caloca DR - vk - fixes for depth/stencil descriptors - Minor debug dump improvement Change 3098463 on 2016/08/23 by Daniel.Wright Static lights with MinRoughness = 1.0 don't get their source shapes drawn into reflection captures, since they are being used as virtual area lights Change 3098556 on 2016/08/23 by Daniel.Wright Lightmass area shadows only mark texels as mapped inside the light's influence, which fixes multiple stationary lights with bUseAreaShadowsForStationaryLight interfering. Change 3098672 on 2016/08/23 by Rolando.Caloca DR - vk - Fixed crash when using vertex shaders with no descriptors Change 3099173 on 2016/08/24 by Ben.Woodhouse Fixed various issues with subsurface profile, for checkerboard and non-checkerboard code paths - Re-enable non-checkerboard skin by default - Checkerboard issues fixed: - Emissive lighting was being applied twice due to not taking checkerboard pattern into account - Emissive lighting was modulated by basecolor in the recombine - Metallic materials were contributing specular lighting to the diffuse channel - Non-checkerboard fixes: - Fix write mask during SkyLightDiffuse so alpha is updated correctly - Metallic specular lighting was broken (specularColor was lerping to white instead of baseColor) - Optimisation: Fall back to default lit for pixels where the opacity is 0. - For non-checkerboard, this gives better handling of metallic/emissive for pixels where SSS is not required (non-CB RGBA encoding for diffuse/spec doesn't cope well with colored specular or emissive) - For checkerboard, this gives similar results in terms of shading, but we get full-resolution shading on non SSS pixels #jira UE-34561 Change 3099673 on 2016/08/24 by Daniel.Wright Removed unused reflection shape variables Change 3099674 on 2016/08/24 by Daniel.Wright Fixed translucent materials not working in DrawMaterialToRenderTarget (fallout from cl 3089208) Fixed ensure with FRendererModule::DrawTile in the forward renderer, trying to bind light attenuation texture Change 3099700 on 2016/08/24 by Daniel.Wright Disabled log spam when a Rift is connected but not being used Change 3099730 on 2016/08/24 by Daniel.Wright MSAA depth resolve uses depth of closest surface, hides some artifacts with dynamic shadowing against the skybox Change 3099789 on 2016/08/24 by Brian.Karis FloatRGB is now always supported. If 11:11:10 isn't supported by hardware this format by definition will map to a different format meaning it is always supported. Change 3099987 on 2016/08/24 by Daniel.Wright Fixed light grid debug asserts on PS4 * Always creating the local light buffer, even if it won't be used by the shader * Transition ViewState FRWBuffers to writable at the beginning of a new frame Change 3100120 on 2016/08/24 by Rolando.Caloca DR - vk - Use 256MB pages for GPU memory Change 3100151 on 2016/08/24 by Daniel.Wright PS4 gracefully falls back to Temporal AA when MSAA is requested, as the GNM RHI doesn't support MSAA yet Change 3100302 on 2016/08/24 by Rolando.Caloca DR - vk - Mem system changes - Now allocates a readback heap from GPU->CPU - Removed bad total memory on heap/type - Added fallback to another mem type if it's OOM Change 3101110 on 2016/08/25 by Rolando.Caloca DR - vk - Remove r.Vulkan.UseGLSL Change 3101121 on 2016/08/25 by Rolando.Caloca DR - vk - Initial support for HiResShot Change 3101450 on 2016/08/25 by Rolando.Caloca DR - vk - Remove imagelayout from textures; renamed a method for clarity Change 3101462 on 2016/08/25 by Daniel.Wright Planar reflections no longer update GPU particles, fixes Scene Depth particle collision Change 3101525 on 2016/08/25 by Frank.Fella Niagara - Remove public include modules from niagara, and remove the public include dependency on niagara from UnrealEd, and fix up fallout. Change 3101613 on 2016/08/25 by Rolando.Caloca DR - vk - Fix static analysis warning Change 3101686 on 2016/08/25 by Frank.Fella Niagara - Move asset type actions into the niagara module. Change 3101865 on 2016/08/25 by Rolando.Caloca DR - vk - Fix compile issue when enabling dump layer Change 3101946 on 2016/08/25 by Frank.Fella Orion - Fix include error caused by niagara include fixup. Change 3101999 on 2016/08/25 by Frank.Fella Fortnite - Fix include error caused by niagara include fixup. Change 3102035 on 2016/08/25 by Frank.Fella Ocean - Fix include error caused by niagara include fixup. Change 3102047 on 2016/08/25 by Frank.Fella UnrealTournament - Fix include error caused by niagara include fixup. Change 3102627 on 2016/08/26 by Frank.Fella Niagara - Move stats group declaration to the niagara module and move the stats declarations in the niagara module into the cpp files. Change 3102654 on 2016/08/26 by Ben.Woodhouse Fix for D3D error with mismatched vertex/pixel shader registers for SV_POSITION input. Remove unused PixelPosition attribute from interpolators #jira UE-33424 Change 3102780 on 2016/08/26 by Ben.Woodhouse Make shadow culling take FOV into account, via LODDistanceFactor Also set the LODDistanceFactorSquared member of the view, which was previously uninitialized #jira UE-33873 Change 3102930 on 2016/08/26 by Rolando.Caloca DR - vk - Do not require backbuffer at start, like Metal Change 3103061 on 2016/08/26 by Rolando.Caloca DR - vk - More debug dump to help track down issues Change 3103143 on 2016/08/26 by Rolando.Caloca DR - vk - Added partial image view for each texture for Depth/Stencil - Removed some unused members from textures Change 3104162 on 2016/08/29 by Gil.Gribb Merging //UE4/Dev-Main@3104155 to Dev-Rendering (//UE4/Dev-Rendering) Change 3104491 on 2016/08/29 by Rolando.Caloca DR - vk - Fix merge issue Change 3104500 on 2016/08/29 by Rolando.Caloca DR - Rebuilt hlslcc libs after merge Change 3104978 on 2016/08/29 by John.Billon -Moved Particle Cutouts to the Required Module -Pre-existing SubUVAnimation data is automatically moved to required on Init. -Added Default Particle Cutouts project setting that will attempt to find and use a texture on a particle's material for a cutout by default. Change 3105249 on 2016/08/29 by John.Billon Fixing non-editor compile error. Change 3105326 on 2016/08/29 by Zabir.Hoque SIMD Movie Player on XB1 Change 3105813 on 2016/08/30 by John.Billon Fixing static analysis warning. Change 3106322 on 2016/08/30 by Matt.Kuhlenschmidt Removed duplicated view uniform shader parameters initialization between slate and scene rendering. Moved all the duped initialization into a single shared method. The shared method should be where new parameters are initialized if they are required for the view to work properly. Change 3106350 on 2016/08/30 by Rolando.Caloca DR - vk - Added missing texture formats - Added texture debug name Change 3106547 on 2016/08/30 by Rolando.Caloca DR - Added ESimpleRenderTargetMode::EExistingColorAndClearDepth Change 3106631 on 2016/08/30 by Uriel.Doyon Dirty Texture Streaming Build do not dirty maps anymore. #jira UE-35241 Change 3106919 on 2016/08/30 by Rolando.Caloca DR - Temp workaround to get Vulkan up & running, might require hlslcc fix Change 3106974 on 2016/08/30 by Uriel.Doyon Changed lightmass exports version from GUID to INT in order to shorten filenames. Change 3106988 on 2016/08/30 by Uriel.Doyon New project specific config value r.Streaming.CheckBuildStatus used to specify whether the engine should check if the "Texture Streaming Build" is dirty (false by default). #jira UE-35227 Change 3107927 on 2016/08/31 by John.Billon -Duplicating OpenGL4 ClearUAV Implementation from 4.13 -Fixed uav clear format. #Jira UE-35345 Change 3108095 on 2016/08/31 by Marc.Olano Restore initialization of noise textures, accidentally removed in @3106322 #jira UE-35369 Change 3108557 on 2016/08/31 by John.Billon Fixing HTML5 compile error [CL 3109297 by Gil Gribb in Main branch]
2016-08-31 21:22:32 -04:00
FOpenGLUnorderedAccessView* Texture = ResourceCast(UnorderedAccessViewRHI);
Copying //UE4/Dev-Mobile to //UE4/Dev-Main (Source: //UE4/Dev-Mobile @ 3116515) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3065209 on 2016/07/26 by Steve.Cano Add Android Texture Format used for packaging/cooking to the Manifest File #ue4 #android #jira UE-33645 Change 3068915 on 2016/07/28 by Steve.Cano Add an additional Texture Compression support line in the manifest for DXT #ue4 #android #jira UE-33645 Change 3075911 on 2016/08/03 by Steve.Cano Make the "Running {ProjectName} on {Device}" toast stay up when launching a game to an Android device until we've finished running it, as it does on other platforms. This logic already existed but only ran if the "Prebuilt" flag was passed in, however we want this to always run now. Re-writing to run through waiting on each process to finish for each device launched on #jira UE-3122 #ue4 #android Change 3080981 on 2016/08/08 by Steve.Cano Clear any input before removing the TouchInterface from the screen to prevent infinite input after it is cleared #jira UE-33956 #ue4 #platform Change 3092587 on 2016/08/17 by Steve.Cano Adding "IsGamepadAttached" functionality to Android Application #jira UE-33264 #ue4 #android Change 3095840 on 2016/08/21 by Dmitriy.Dyomin Fixed: Particle Cutout Crashes On Certain Devices (Samsung Galaxy Note 2) Happens only with non-instanced path #jira UE-34604 Change 3095855 on 2016/08/22 by Dmitriy.Dyomin Allow UWorldComposition::GetTilesList to be used in runtime code Licensee request https://udn.unrealengine.com/questions/307586/world-compositions-world-dimensions.html Change 3096093 on 2016/08/22 by Allan.Bentham Allow Vulkan api logging on android Change 3096361 on 2016/08/22 by Steve.Cano Github 2663 pull - Pass any extras used to launch SplashActivity down to GameActivity (Contributed by sangpan) #jira UE-34050 #github #2663 #ue4 #android Change 3097412 on 2016/08/23 by Dmitriy.Dyomin Using BulkSerialize for cooked collision data to speed up serialization Change 3098957 on 2016/08/23 by Jack.Porter Merging //UE4/Dev-Main to Dev-Mobile (//UE4/Dev-Mobile) Change 3099058 on 2016/08/24 by Jack.Porter Check EXT_debug_label and EXT_debug_marker functions were found before calling as a few devices to not implement these extensions #UE-35087 Change 3099131 on 2016/08/24 by Dmitriy.Dyomin Fixed: HDR compressed texture become black in some mali devices Use sized internal format for half-float textures on ES3 devices, as ES3 spec expects it #jira UE-35018 Change 3099150 on 2016/08/24 by Dmitriy.Dyomin Enable HALF_FLOAT and UNSIGNED_INT_2_10_10_10_REV vertex formats on ES3+ devices, spec req Change 3102252 on 2016/08/26 by Dmitriy.Dyomin Prevent view uniform buffer crash on ES2 devices that do not support 3D textures Change 3102258 on 2016/08/26 by Dmitriy.Dyomin Enabled refraction on iPadMini4 #jira UE-35079 Change 3102651 on 2016/08/26 by Dmitriy.Dyomin Fixed: instanced static mesh world normals Also removed unnecessary instance matrix transposing #jira UE-35075 Change 3109397 on 2016/09/01 by Jack.Porter Fix problem with Android sessions not appearing in Session Frontend #jira UE-35261 Change 3109490 on 2016/09/01 by Jack.Porter Merging //UE4/Dev-Main to Dev-Mobile (//UE4/Dev-Mobile) Change 3111628 on 2016/09/02 by Jack.Porter Landscape wireframe LOD visualization with tessellation Change 3112809 on 2016/09/02 by Chris.Babcock Update cached length when file is written to on Android #jira UE-35558 #ue4 #android Change 3113245 on 2016/09/04 by Dmitriy.Dyomin Fixed: Subway Sequencer plays only a black screen when packaged for ESDSR (3.1+AEP) #jira UE-34291 Change 3113249 on 2016/09/04 by Dmitriy.Dyomin Replicated fix from 4.13: GPU particles no longer work on iOS or TVOS Metal devices #jira UE-34782 Change 3113513 on 2016/09/05 by Allan.Bentham Add vulkan version parameter to android device profile selector's source inputs . reinstate Vulkan Disable cvar functionality. Added mali no vulkan device profile. Change 3113519 on 2016/09/05 by Allan.Bentham Remove temp 4.13 hack to avoid public header changes. Change 3113535 on 2016/09/05 by Allan.Bentham Decode 32 bit HDR formats when using scene captures. #jira UE-25444 Change 3113813 on 2016/09/06 by Dmitriy.Dyomin Resend to server sub-levels visibility state right after world actors are initialized. During seamless travel client loads always-loaded sub-levels before world actors are initialized and ServerUpdateLevelVisibility calls in UWorld::AddToWorld are skipped. Change 3113870 on 2016/09/06 by Jack.Porter Fix issue with ES2 Feature Level preview and Mobile Preview PIE not limiting materials to 8 textures #jira UE-35591 Change 3115031 on 2016/09/06 by Chris.Babcock Add Vulkan version code not moved over from 4.13.1 #jira UE-35642 #ue4 #android Change 3115496 on 2016/09/07 by Dmitriy.Dyomin Use the same DDC key for source reflection data and encoded data. Fixes broken reflections on mobile #jira UE-35647 [CL 3116720 by Chris Babcock in Main branch]
2016-09-07 17:04:11 -04:00
// Use compute on ES3.1
TRHICommandList_RecursiveHazardous<FOpenGLDynamicRHI> RHICmdList(this);
if (Texture->GetBufferSize() == 0)
{
FOpenGLTextureUnorderedAccessView* Texture2D = static_cast<FOpenGLTextureUnorderedAccessView*>(Texture);
FIntVector Size = Texture2D->TextureRHI->GetSizeXYZ();
if (Texture->IsLayered())
{
ClearUAVShader_T<EClearReplacementResourceType::Texture3D, EClearReplacementValueType::Float, 4, false>(RHICmdList, UnorderedAccessViewRHI, Size.X, Size.Y, Size.Z, *reinterpret_cast<const float(*)[4]>(&Values));
}
else
{
ClearUAVShader_T<EClearReplacementResourceType::Texture2D, EClearReplacementValueType::Float, 4, false>(RHICmdList, UnorderedAccessViewRHI, Size.X, Size.Y, Size.Z, *reinterpret_cast<const float(*)[4]>(&Values));
}
}
else
{
check(Texture->BufferResource);
{
int32 NumComponents = 0;
uint32 NumElements = 0;
if (Texture->UnrealFormat != 0)
{
NumComponents = GPixelFormats[Texture->UnrealFormat].NumComponents;
NumElements = Texture->GetBufferSize() / GPixelFormats[Texture->UnrealFormat].BlockBytes;
}
else
{
NumElements = Texture->GetBufferSize() / sizeof(float);
NumComponents = 1;
}
switch (NumComponents)
{
case 1:
ClearUAVShader_T<EClearReplacementResourceType::Buffer, EClearReplacementValueType::Float, 1, false>(RHICmdList, UnorderedAccessViewRHI, NumElements, 1, 1, *reinterpret_cast<const float(*)[1]>(&Values));
break;
case 4:
ClearUAVShader_T<EClearReplacementResourceType::Buffer, EClearReplacementValueType::Float, 4, false>(RHICmdList, UnorderedAccessViewRHI, NumElements, 1, 1, *reinterpret_cast<const float(*)[4]>(&Values));
break;
default:
check(false);
};
}
}
}
void FOpenGLDynamicRHI::RHIClearUAVUint(FRHIUnorderedAccessView* UnorderedAccessViewRHI, const FUintVector4& Values)
{
FOpenGLUnorderedAccessView* Texture = ResourceCast(UnorderedAccessViewRHI);
TRHICommandList_RecursiveHazardous<FOpenGLDynamicRHI> RHICmdList(this);
if (Texture->GetBufferSize() == 0)
{
FOpenGLTextureUnorderedAccessView* Texture2D = static_cast<FOpenGLTextureUnorderedAccessView*>(Texture);
FIntVector Size = Texture2D->TextureRHI->GetSizeXYZ();
if (Texture->IsLayered())
{
ClearUAVShader_T<EClearReplacementResourceType::Texture3D, EClearReplacementValueType::Uint32, 4, false>(RHICmdList, UnorderedAccessViewRHI, Size.X, Size.Y, Size.Z, *reinterpret_cast<const uint32(*)[4]>(&Values));
}
else
{
ClearUAVShader_T<EClearReplacementResourceType::Texture2D, EClearReplacementValueType::Uint32, 4, false>(RHICmdList, UnorderedAccessViewRHI, Size.X, Size.Y, Size.Z, *reinterpret_cast<const uint32(*)[4]>(&Values));
}
}
else
{
check(Texture->BufferResource);
{
int32 NumComponents = 0;
uint32 NumElements = 0;
if (Texture->UnrealFormat != 0)
{
NumComponents = GPixelFormats[Texture->UnrealFormat].NumComponents;
NumElements = Texture->GetBufferSize() / GPixelFormats[Texture->UnrealFormat].BlockBytes;
}
else
{
NumElements = Texture->GetBufferSize() / sizeof(uint32);
NumComponents = 1;
}
switch (NumComponents)
{
case 1:
ClearUAVShader_T<EClearReplacementResourceType::Buffer, EClearReplacementValueType::Uint32, 1, false>(RHICmdList, UnorderedAccessViewRHI, NumElements, 1, 1, *reinterpret_cast<const uint32(*)[1]>(&Values));
break;
case 4:
ClearUAVShader_T<EClearReplacementResourceType::Buffer, EClearReplacementValueType::Uint32, 4, false>(RHICmdList, UnorderedAccessViewRHI, NumElements, 1, 1, *reinterpret_cast<const uint32(*)[4]>(&Values));
break;
default:
check(false);
};
}
}
}