Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [numthreads(8, 8, 1)]
- void GenerateMipmapsMax(uint GI : SV_GroupIndex, uint3 DTid : SV_DispatchThreadID)
- {
- SAMPLER_TYPE src0;
- SAMPLER_TYPE src1;
- SAMPLER_TYPE src2;
- SAMPLER_TYPE src3;
- SAMPLER_TYPE max0;
- // Sample each pixel and perform max when needed due to non-power-of-two
- float2 uv = (DTid.xy + 0.5f) * texelSize;
- if (npotFlag == 0)
- {
- src0 = srcLevel.SampleLevel(srcSampler, uv, srcMiplevel);
- }
- else if (npotFlag == 1)
- {
- src0 = max(srcLevel.SampleLevel(srcSampler, uv, srcMiplevel), srcLevel.SampleLevel(srcSampler, uv + float2(texelSize.x, 0.0f), srcMiplevel));
- }
- else if (npotFlag == 2)
- {
- src0 = max(srcLevel.SampleLevel(srcSampler, uv, srcMiplevel), srcLevel.SampleLevel(srcSampler, uv + float2(0.0f, texelSize.y), srcMiplevel));
- }
- else
- {
- src0 = max(max(srcLevel.SampleLevel(srcSampler, uv, srcMiplevel), srcLevel.SampleLevel(srcSampler, uv + float2(texelSize.x, 0.0f), srcMiplevel)),
- max(srcLevel.SampleLevel(srcSampler, uv + float2(0.0f, texelSize.y), srcMiplevel), srcLevel.SampleLevel(srcSampler, uv + float2(texelSize.x, texelSize.y), srcMiplevel)));
- }
- StoreColor(GI, src0);
- GroupMemoryBarrierWithGroupSync();
- if ((GI & 0x9) == 0)
- {
- src1 = LoadColor(GI + 0x01);
- src2 = LoadColor(GI + 0x08);
- src3 = LoadColor(GI + 0x09);
- max0 = max(max(src0, src1), max(src2, src3));
- mipLevel1[DTid.xy / 2] = max0;
- StoreColor(GI, max0);
- }
- if (mipLevels == 1)
- {
- return;
- }
- GroupMemoryBarrierWithGroupSync();
- if ((GI & 0x1B) == 0)
- {
- src1 = LoadColor(GI + 0x02);
- src2 = LoadColor(GI + 0x10);
- src3 = LoadColor(GI + 0x12);
- max0 = max(max(src0, src1), max(src2, src3));
- mipLevel2[DTid.xy / 4] = max0;
- StoreColor(GI, max0);
- }
- if (mipLevels == 2)
- {
- return;
- }
- GroupMemoryBarrierWithGroupSync();
- if (GI == 0)
- {
- src1 = LoadColor(GI + 0x04);
- src2 = LoadColor(GI + 0x20);
- src3 = LoadColor(GI + 0x24);
- max0 = max(max(src0, src1), max(src2, src3));
- mipLevel3[DTid.xy / 8] = max0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement