Skip to content

Commit

Permalink
Working on generate mips
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Krupitskas committed Jul 28, 2024
1 parent 632c585 commit 0585bc6
Show file tree
Hide file tree
Showing 12 changed files with 386 additions and 373 deletions.
15 changes: 8 additions & 7 deletions Shaders/GenerateMipsCS.hlsl → Shaders/GenerateMips.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ SamplerState LinearClampSampler : register(s0);
// The reason for separating channels is to reduce bank conflicts in the
// local data memory controller. A large stride will cause more threads
// to collide on the same memory bank.

groupshared float gs_R[64];
groupshared float gs_G[64];
groupshared float gs_B[64];
Expand All @@ -69,15 +68,19 @@ float4 LoadColor(uint Index)

float3 ConvertToLinear(float3 x)
{
return x < 0.04045f ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4);
}
return float3(0,0,0);

// TODO(mips): Fix that
//return x < 0.04045f ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4);
}

float3 ConvertToSRGB(float3 x)
{
return x < 0.0031308 ? 12.92 * x : 1.055 * pow(abs(x), 1.0 / 2.4) - 0.055;
}
return float3(0,0,0);

// TODO(mips): Fix that
//return x < 0.0031308 ? 12.92 * x : 1.055 * pow(abs(x), 1.0 / 2.4) - 0.055;
}

float4 PackColor(float4 x)
{
Expand All @@ -91,8 +94,6 @@ float4 PackColor(float4 x)
}
}



[RootSignature(GenerateMips_RootSignature)]
[numthreads(8, 8, 1)]
void main(ComputeShaderInput IN)
Expand Down
3 changes: 1 addition & 2 deletions Yasno/Renderer/ShaderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ namespace ysn
std::string error_msg = "Shader Compiler Error: ";
error_msg.append(info_log.data());

LogError << "Failed compile shader\n"
<< error_msg.c_str() << "\n";
LogFatal << "Failed compile shader\n" << error_msg.c_str() << "\n";
return std::nullopt;
}

Expand Down
6 changes: 6 additions & 0 deletions Yasno/Renderer/Texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@

namespace ysn
{
// TODO: make it class, GpuTexture, UAV non uav, get rid of scratch buffer, keep if it's srgb
struct Texture
{
DescriptorHandle descriptor_handle;

wil::com_ptr<ID3D12Resource> gpuTexture;
wil::com_ptr<ID3D12Resource> textureUploadHeap; // TODO(task): Delete it after texture uploaded!

bool SupportsUav() const
{
return false;
}
};

// TODO: TextureUsage textureUsage for srgb
Expand Down
Loading

0 comments on commit 0585bc6

Please sign in to comment.