Code Monkey home page Code Monkey logo

Comments (2)

PanosK92 avatar PanosK92 commented on August 24, 2024

Hi Kliaxe,

Thanks for your kind words, I'm glad you find it helpful 😃

Try removing g_padding from the struct...

struct FrameBuffer
{
    Math::Matrix view;
    Math::Matrix projection;
    Math::Matrix projection_ortho;
    Math::Matrix view_projection;
    Math::Matrix view_projection_inv;
    Math::Matrix view_projection_ortho;
    Math::Matrix view_projection_unjittered;

    ...

    float ssr_enabled;
    float shadow_resolution;
    float ssao_scale;
    float white_balance;
};

... and from the cbuffer

cbuffer FrameBuffer : register(b0)
{
	matrix g_view;
	matrix g_projection;
	matrix g_projectionOrtho;
	matrix g_viewProjection;
	matrix g_viewProjectionInv;
	matrix g_viewProjectionOrtho;
	matrix g_viewProjectionUnjittered;

        ...
	
	float g_ssr_enabled;
	float g_shadow_resolution;
	float g_ssao_scale;
	float g_white_balance;
};

It should work now.

This is because HLSL has some packing/alignment rules for constant buffers (16-byte boundaries), detailed here.

On top of that, the compiler can choose to add padding to something like a struct, introducing a potential scenario where what you map from the CPU, is different from what the GPU expects.

So it's a good idea to explicitly/manually ensure correct padding both on the CPU and the GPU.

I hope this helps 👍

from spartanengine.

Kliaxe avatar Kliaxe commented on August 24, 2024

Hello, thank you for the quick answer! Yes, that definitely did the trick!
I'm now closing this issue as the problem has been solved.

from spartanengine.

Related Issues (20)

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.