mirror of
https://github.com/hedge-dev/XenosRecomp.git
synced 2025-12-23 00:12:20 +00:00
Implement texture offsets.
This commit is contained in:
parent
b152142709
commit
6477f65937
2 changed files with 37 additions and 5 deletions
|
|
@ -42,9 +42,25 @@ Texture3D<float4> g_Texture3DDescriptorHeap[] : register(t0, space1);
|
|||
TextureCube<float4> g_TextureCubeDescriptorHeap[] : register(t0, space2);
|
||||
SamplerState g_SamplerDescriptorHeap[] : register(s0, space3);
|
||||
|
||||
float4 tfetch2D(uint resourceDescriptorIndex, uint samplerDescriptorIndex, float2 texCoord)
|
||||
|
||||
float4 tfetch2D(uint resourceDescriptorIndex, uint samplerDescriptorIndex, float2 texCoord, float2 offset)
|
||||
{
|
||||
return g_Texture2DDescriptorHeap[resourceDescriptorIndex].Sample(g_SamplerDescriptorHeap[samplerDescriptorIndex], texCoord);
|
||||
Texture2D<float4> texture = g_Texture2DDescriptorHeap[resourceDescriptorIndex];
|
||||
|
||||
uint2 dimensions;
|
||||
texture.GetDimensions(dimensions.x, dimensions.y);
|
||||
|
||||
return texture.Sample(g_SamplerDescriptorHeap[samplerDescriptorIndex], texCoord + offset / dimensions);
|
||||
}
|
||||
|
||||
float2 getWeights2D(uint resourceDescriptorIndex, uint samplerDescriptorIndex, float2 texCoord, float2 offset)
|
||||
{
|
||||
Texture2D<float4> texture = g_Texture2DDescriptorHeap[resourceDescriptorIndex];
|
||||
|
||||
uint2 dimensions;
|
||||
texture.GetDimensions(dimensions.x, dimensions.y);
|
||||
|
||||
return frac(texCoord * dimensions + offset - 0.5);
|
||||
}
|
||||
|
||||
float4 tfetch3D(uint resourceDescriptorIndex, uint samplerDescriptorIndex, float3 texCoord)
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ void ShaderRecompiler::recompile(const VertexFetchInstruction& instr, uint32_t a
|
|||
|
||||
void ShaderRecompiler::recompile(const TextureFetchInstruction& instr)
|
||||
{
|
||||
if (instr.opcode != FetchOpcode::TextureFetch)
|
||||
if (instr.opcode != FetchOpcode::TextureFetch && instr.opcode != FetchOpcode::GetTextureWeights)
|
||||
return;
|
||||
|
||||
if (instr.isPredicated)
|
||||
|
|
@ -233,7 +233,16 @@ void ShaderRecompiler::recompile(const TextureFetchInstruction& instr)
|
|||
print("r{}.", instr.dstRegister);
|
||||
printDstSwizzle(instr.dstSwizzle, false);
|
||||
|
||||
out += " = tfetch";
|
||||
out += " = ";
|
||||
switch (instr.opcode)
|
||||
{
|
||||
case FetchOpcode::TextureFetch:
|
||||
out += "tfetch";
|
||||
break;
|
||||
case FetchOpcode::GetTextureWeights:
|
||||
out += "getWeights";
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t componentCount = 0;
|
||||
switch (instr.dimension)
|
||||
|
|
@ -267,8 +276,15 @@ void ShaderRecompiler::recompile(const TextureFetchInstruction& instr)
|
|||
for (size_t i = 0; i < componentCount; i++)
|
||||
out += SWIZZLES[((instr.srcSwizzle >> (i * 2))) & 0x3];
|
||||
|
||||
if (instr.dimension == TextureDimension::TextureCube)
|
||||
switch (instr.dimension)
|
||||
{
|
||||
case TextureDimension::Texture2D:
|
||||
print(", float2({}, {})", instr.offsetX * 0.5f, instr.offsetY * 0.5f);
|
||||
break;
|
||||
case TextureDimension::TextureCube:
|
||||
out += ", cubeMapData";
|
||||
break;
|
||||
}
|
||||
|
||||
out += ").";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue