-
Notifications
You must be signed in to change notification settings - Fork 71
IR to HLSL reference backend #1076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // Copyright (C) 2018-2026 - DevSH Graphics Programming Sp. z O.O. | ||
| // This file is part of the "Nabla Engine". | ||
| // For conditions of distribution and use, see copyright notice in nabla.h | ||
| #ifndef _NBL_ASSET_MATERIAL_COMPILER_V3_C_REFERENCE_UNIDIRECTIONAL_PATH_TRACING_H_INCLUDED_ | ||
| #define _NBL_ASSET_MATERIAL_COMPILER_V3_C_REFERENCE_UNIDIRECTIONAL_PATH_TRACING_H_INCLUDED_ | ||
|
|
||
| #include "nbl/asset/material_compiler3/IBackend.h" | ||
|
|
||
| namespace nbl::asset::material_compiler3 | ||
| { | ||
|
|
||
| //template<uint32_t hash0, uint32_t hash1, uint32_t hash2, uint32_t hash3, uint32_t hash4, uint32_t hash5, uint32_t hash6, uint32_t hash7> | ||
| struct OrientedMaterial | ||
| { | ||
| uint32_t emitter_id; | ||
| uint32_t prefetch_offset; | ||
| uint32_t prefetch_count; | ||
| uint32_t instr_offset; | ||
| uint32_t rem_pdf_count; | ||
| uint32_t nprecomp_count; | ||
| uint32_t genchoice_count; | ||
|
Comment on lines
+15
to
+21
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont use raw int (you'll get implicit conversions), use a int wrapped in a struct so its typed |
||
|
|
||
| core::blake3_hash_t hash; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't need to store the hash, because the function handles uniquely determine the material |
||
|
|
||
| struct stream_t | ||
| { | ||
| uint32_t first; | ||
| uint32_t count; | ||
| }; | ||
| stream_t get_rem_and_pdf() const { return { instr_offset, rem_pdf_count }; } | ||
| stream_t get_gen_choice() const { return { instr_offset + rem_pdf_count, genchoice_count }; } | ||
| stream_t get_norm_precomp() const { return { instr_offset + rem_pdf_count + genchoice_count, nprecomp_count }; } | ||
| stream_t get_tex_prefetch() const { return { prefetch_offset, prefetch_count }; } | ||
|
Comment on lines
+25
to
+33
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you copied too much stoff from old material compiler, you're not making a VM you just need a functionID/handle per function, thats all |
||
| }; | ||
|
|
||
| class CReferenceUnidirectionalPathTracing : public IBackend | ||
| { | ||
| public: | ||
| struct CResult : public IBackend::IResult | ||
| { | ||
| //has to go after #version and before required user-provided descriptors and functions | ||
| std::string fragmentShaderSource_declarations; | ||
| //has to go after required user-provided descriptors and functions and before the rest of shader (especially entry point function) | ||
| std::string fragmentShaderSource; | ||
|
Comment on lines
+41
to
+44
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I only want common (the templated functions) and raytracingPipeline (which maps entrypoints to templated functions) remove the comments, they wont apply to HLSL anymore |
||
| }; | ||
|
|
||
| CResult compile(const CTrueIR* ir, const std::span<const CTrueIR::SMaterialHandle> materials); | ||
|
|
||
| private: | ||
| std::string getHashAs4UintsString(const CTrueIR::INode* node, const CTrueIR* ir, const std::string& separator = ",") const; | ||
|
|
||
| void getAlbedoHLSLCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir); | ||
|
|
||
| void getNormalHLSLCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir); | ||
|
|
||
| void getAOVThroughputHLSLCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir); | ||
|
|
||
| void getTransparencyHLSLCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir); | ||
|
|
||
| void getGenerateHLSLCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir); | ||
|
|
||
| void getQuotientWeightHLSLCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir); | ||
|
|
||
| void getEvalWeightHLSLCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir); | ||
|
|
||
| void getEmissionHLSLCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir); | ||
| }; | ||
|
|
||
| } | ||
|
|
||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright (C) 2018-2026 - DevSH Graphics Programming Sp. z O.O. | ||
| // This file is part of the "Nabla Engine". | ||
| // For conditions of distribution and use, see copyright notice in nabla.h | ||
| #ifndef _NBL_ASSET_MATERIAL_COMPILER_V3_I_BACKEND_H_INCLUDED_ | ||
| #define _NBL_ASSET_MATERIAL_COMPILER_V3_I_BACKEND_H_INCLUDED_ | ||
|
|
||
| #include "nbl/asset/material_compiler3/CTrueIR.h" | ||
|
|
||
| namespace nbl::asset::material_compiler3 | ||
| { | ||
|
|
||
| class IBackend | ||
| { | ||
| public: | ||
| struct IResult// : public core::IReferenceCounted | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. class, and yes make it refcounted, make the |
||
| { | ||
|
|
||
| }; | ||
|
|
||
| IResult compile(const CTrueIR*, const std::span<const CTrueIR::SMaterialHandle>); | ||
| }; | ||
|
|
||
| } | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the hash stuff is only for the HLSL