Giter VIP home page Giter VIP logo

fidelityfx-variableshading's Introduction

FidelityFX Variable Shading

Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Variable Shading

Variable Shading is a technique to generate image based VRS based on luminance of samples in the previous frame. The directory structure is as follows:

You can find the binaries for FidelityFX Variable Shading in the release section on GitHub.

fidelityfx-variableshading's People

Contributors

rys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fidelityfx-variableshading's Issues

Using FidelityFX Variable Shading in Vulkan

This library only seems to support DirectX 12 and HLSL out of the box. Out of curiosity, are there any Vulkan + GLSL ports of this library available (including third-party ports)?

Error base offset when lds fill datas.

Hi, i'm using AMD Variable shading, and there is a bug:

in FFX_VariableShading_GenerateVrsImage (Non-additional shading rate version) function,

when compute baseOffset, AMD use code like this:

int2 baseOffset = tileOffset + int2(-2, -2);

but actually FFX_VariableShading detect edge on one wave just using border 1x1, so i guess this should be:

int2 baseOffset = tileOffset + int2(-1, -1);

ffx_variable_shading.h compute shader

Can you explain how the compute shader and related threadgroups work?

From C++ code:

FFX_VariableShading_GetDispatchInfo(data, AdditionalShadingRates(), w, h);
pCmdLst->Dispatch(w, h, 1);
// coarse tiles are potentially 2x2, so each thread computes 2x2 pixels
if (cb->tileSize == 8)
{
    //each threadgroup computes 4 VRS tiles
    numThreadGroupsX = FFX_VariableShading_DivideRoundingUp(vrsImageWidth, 2);
    numThreadGroupsY = FFX_VariableShading_DivideRoundingUp(vrsImageHeight, 2);
}

From VRSImageGenCS.hlsl (static const uint FFX_VariableShading_ThreadCount1D = 8;)

[numthreads(FFX_VariableShading_ThreadCount1D, FFX_VariableShading_ThreadCount1D, 1)]
void mainCS(
    uint3 Gid  : SV_GroupID,
    uint3 Gtid : SV_GroupThreadID,
    uint  Gidx : SV_GroupIndex)
{
    FFX_VariableShading_GenerateVrsImage(Gid, Gtid, Gidx);
}

From ffx_variable_shading.h:

// sample source texture (using motion vectors)
while (index < FFX_VariableShading_SampleCount)
{
    int2 index2D = 2 * int2(index % FFX_VariableShading_SampleCount1D, index / FFX_VariableShading_SampleCount1D);
    float4 lum = 0;
    lum.x = FFX_VariableShading_GetLuminance(baseOffset + index2D + int2(0, 0));
    lum.y = FFX_VariableShading_GetLuminance(baseOffset + index2D + int2(1, 0));
    lum.z = FFX_VariableShading_GetLuminance(baseOffset + index2D + int2(0, 1));
    lum.w = FFX_VariableShading_GetLuminance(baseOffset + index2D + int2(1, 1));
    ...
    index += FFX_VariableShading_ThreadCount;

For example, suppose we have an image that's 1080x3200 with 8x8 tiles, so the VRS image is 135 x 400. Suppose our example supports up to 2x2 coarse pixel size, so numThreadGroupsX is 68, numThreadGroupsY is 200. Why is it 68x200? 4 VRS tiles (2x2 tiles) per thread. Each threadgroup is 8x8 threads and computes 4 VRS tiles (2x2 VRS tiles is 16x16 pixels) (each thread gets luminance for a 2x2 pixels x 8x8 threads = 16x16 pixels). I think that sort of makes sense...

However, what is while (index < FFX_VariableShading_SampleCount) doing? while (index < 100) { do stuff then index += 64 }. What is this while loop doing? Is it okay to comment it out?

static const uint FFX_VariableShading_ThreadCount1D = 8;
static const uint FFX_VariableShading_SampleCount1D = FFX_VariableShading_ThreadCount1D + 2; // 10
static const uint FFX_VariableShading_SampleCount = FFX_VariableShading_SampleCount1D * FFX_VariableShading_SampleCount1D; // 100
static const uint FFX_VariableShading_ThreadCount = FFX_VariableShading_ThreadCount1D * FFX_VariableShading_ThreadCount1D; // 64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.