You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
53 lines
2.1 KiB
Plaintext
53 lines
2.1 KiB
Plaintext
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
UpdateTextureShaders.usf: Compute shaders for copying and updating textures.
|
|
=============================================================================*/
|
|
|
|
#include "Common.usf"
|
|
|
|
Buffer<int> SrcBuffer;
|
|
RWTexture2D<int4> DestTexture;
|
|
uint SrcPitch; //number of SrcBuffer elements in a row of the source area
|
|
|
|
|
|
uint4 DestPosSize; // xy = pos, zw = Size of the destination sub rect
|
|
|
|
[numthreads(8,8,1)]
|
|
void UpdateTexture2DSubresourceCS( uint2 ThreadId : SV_DispatchThreadID )
|
|
{
|
|
if( all( ThreadId.xy < DestPosSize.zw ) )
|
|
{
|
|
int2 TexturePixelOffset = ThreadId.xy + DestPosSize.xy;
|
|
|
|
//supports textures with 1-4 components. Textures with < 4 components will simply ignore writes to the extra components via channel masking.
|
|
int BufferOffset = ThreadId.x + (ThreadId.y * SrcPitch);
|
|
DestTexture[TexturePixelOffset] = int4(SrcBuffer[BufferOffset].x, SrcBuffer[BufferOffset + 1].x, SrcBuffer[BufferOffset + 2].x, SrcBuffer[BufferOffset + 3].x);
|
|
}
|
|
}
|
|
|
|
RWTexture3D<int4> DestTexture3D;
|
|
uint SrcDepthPitch; //number of SrcBuffer entries between z slices of the source volume
|
|
uint4 DestPos; // xyz = starting offset in destination volume texture
|
|
uint4 DestSize; //syz = size of the volume to update
|
|
|
|
[numthreads(8, 8, 1)]
|
|
void UpdateTexture3DSubresourceCS(uint3 ThreadId : SV_DispatchThreadID)
|
|
{
|
|
if (all(ThreadId.xyz < DestSize.xyz))
|
|
{
|
|
int3 TexturePixelOffset = ThreadId.xyz + (int3)DestPos.xyz;
|
|
|
|
//supports textures with 1-4 components. Textures with < 4 components will simply ignore writes to the extra components via channel masking.
|
|
int BufferOffset = ThreadId.x + (ThreadId.y * SrcPitch) + (ThreadId.z * SrcDepthPitch);
|
|
DestTexture3D[TexturePixelOffset] = int4(SrcBuffer[BufferOffset].x, SrcBuffer[BufferOffset + 1].x, SrcBuffer[BufferOffset + 2].x, SrcBuffer[BufferOffset + 3].x);
|
|
}
|
|
}
|
|
|
|
Texture2D<int4> SrcTexture;
|
|
|
|
[numthreads(8,8,1)]
|
|
void CopyTexture2DCS( uint3 ThreadId : SV_DispatchThreadID )
|
|
{
|
|
DestTexture[ThreadId.xy] = SrcTexture.Load(int3(ThreadId.x, ThreadId.y, 0));
|
|
} |