Skip to content

Commit 7b6a5ef

Browse files
Merge pull request #638 from Devsh-Graphics-Programming/vulkan_1_3_examples_fix
Fix some bad comparators of image feature reqs and default cmake vars
2 parents ef7171f + 50db489 commit 7b6a5ef

File tree

6 files changed

+56
-46
lines changed

6 files changed

+56
-46
lines changed

include/nbl/asset/utils/CSPIRVIntrospector.h

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For conditions of distribution and use, see copyright notice in nabla.h
44
#ifndef _NBL_ASSET_C_SPIRV_INTROSPECTOR_H_INCLUDED_
55
#define _NBL_ASSET_C_SPIRV_INTROSPECTOR_H_INCLUDED_
6-
6+
#if 0
77
#include "nbl/core/declarations.h"
88

99
#include <cstdint>
@@ -27,6 +27,20 @@ namespace spirv_cross
2727
struct SPIRType;
2828
}
2929

30+
// podzielic CIntrospectionData na dwie klasy
31+
// jedna bez inputOutput i bez push constant blocka `CIntrospectionData`
32+
// druga dziedziczy z pierwszej i dodaje te 2 rzeczy `CStageIntrospectionData`
33+
34+
// wszystkie struktury w CIntrospecionData powininny u¿ywaæ bit flagi, ozaczaj¹cej shader stage (core::unordered_map)
35+
// CStageIntrospecionData nie powinien u¿ywaæ bit flagi, ozaczaj¹cej shader stage (core::vector)
36+
37+
// hashowane s¹ tylko set i binding
38+
// dla spec constant tylko specConstantID
39+
// validacja kolizji (dla SSpecConstants mo¿e siê jedynie ró¿niæ name)
40+
// ogarn¹æ sytuacje gdy jeden descriptor binding ma wiêcej arrayElementCount ni¿ w SPIR-V
41+
// w `CStageIntrospectionData` powinien byæ trzymana struktura `SIntrospectionParams`
42+
43+
//
3044
namespace nbl::asset
3145
{
3246
class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
@@ -88,6 +102,7 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
88102
//! Sorted by `location`
89103
core::vector<SShaderInfoVariant> inputOutput;
90104

105+
//! Push constants uniform block
91106
struct {
92107
bool present;
93108
core::string name;
@@ -123,7 +138,7 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
123138
return false;
124139
if (cpuShader->getContent()->getSize() != rhs.cpuShader->getContent()->getSize())
125140
return false;
126-
return memcmp(cpuShader->getContent()->getPointer(), rhs.cpuShader->getContent()->getPointer(), cpuShader->getContent()->getSize()) == 0;;
141+
return memcmp(cpuShader->getContent()->getPointer(), rhs.cpuShader->getContent()->getPointer(), cpuShader->getContent()->getSize()) == 0;
127142
}
128143
};
129144

@@ -132,43 +147,26 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
132147

133148
//! params.cpuShader.contentType should be ECT_SPIRV
134149
//! the compiled SPIRV must be compiled with IShaderCompiler::SCompilerOptions::debugInfoFlags enabling EDIF_SOURCE_BIT implicitly or explicitly, with no `spirvOptimizer` used in order to include names in introspection data
150+
// powinna zwracac CStageIntrospectionData
135151
core::smart_refctd_ptr<const CIntrospectionData> introspect(const SIntrospectionParams& params, bool insertToCache = true);
136152

153+
//
154+
//core::smart_refctd_ptr<const CIntrospectionData> merge(const std::span<const CStageIntrospectionData>& asdf, const ICPUShader::SSPecInfo::spec_constant_map_t& = {});
155+
137156
// When the methods take a span of shaders, they are computing things for an imaginary pipeline that includes **all** of them
157+
// przeniesc do CIntrospectionData
138158
std::pair<bool/*is shadow sampler*/, IImageView<ICPUImage>::E_TYPE> getImageInfoFromIntrospection(uint32_t set, uint32_t binding, const std::span<const ICPUShader::SSpecInfo> _infos);
139-
140-
inline core::smart_refctd_dynamic_array<SPushConstantRange> createPushConstantRangesFromIntrospection(const std::span<const ICPUShader::SSpecInfo> _infos)
141-
{
142-
core::vector<core::smart_refctd_ptr<const CIntrospectionData>> introspections(_infos.size());
143-
if (!introspectAllShaders(introspections.data(),_infos))
144-
return nullptr;
145-
146-
return createPushConstantRangesFromIntrospection_impl(introspections.data(),_infos);
147-
}
148-
inline core::smart_refctd_ptr<ICPUDescriptorSetLayout> createApproximateDescriptorSetLayoutFromIntrospection(uint32_t set, const std::span<const ICPUShader::SSpecInfo> _infos)
149-
{
150-
core::vector<core::smart_refctd_ptr<const CIntrospectionData>> introspections(_infos.size());
151-
if (!introspectAllShaders(introspections.data(),_infos))
152-
return nullptr;
153-
154-
return createApproximateDescriptorSetLayoutFromIntrospection_impl(set,introspections.data(), _infos);
155-
}
156-
inline core::smart_refctd_ptr<ICPUPipelineLayout> createApproximatePipelineLayoutFromIntrospection(const std::span<const ICPUShader::SSpecInfo> _infos)
157-
{
158-
core::vector<core::smart_refctd_ptr<const CIntrospectionData>> introspections(_infos.size());
159-
if (!introspectAllShaders(introspections.data(),_infos))
160-
return nullptr;
161-
162-
return createApproximatePipelineLayoutFromIntrospection_impl(introspections.data(),_infos);
163-
}
164159

165160
//
166161
inline core::smart_refctd_ptr<ICPUComputePipeline> createApproximateComputePipelineFromIntrospection(const ICPUShader::SSpecInfo& info)
162+
//TODO: inline core::smart_refctd_ptr<ICPUComputePipeline> createApproximateComputePipelineFromIntrospection(CStageIntrospectionData* asdf)
167163
{
168164
if (info.shader->getStage()!=IShader::ESS_COMPUTE)
169165
return nullptr;
170166

171167
core::smart_refctd_ptr<const CIntrospectionData> introspection = nullptr;
168+
169+
//TODO: zamiast tego mergujemy `CStageIntrospectionData` w `CIntrospectionData` u¿ywaj¹c `merge`
172170
if (!introspectAllShaders(&introspection,{&info,1}))
173171
return nullptr;
174172

@@ -180,15 +178,24 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
180178

181179
//
182180
core::smart_refctd_ptr<ICPURenderpassIndependentPipeline> createApproximateRenderpassIndependentPipelineFromIntrospection(const std::span<const ICPUShader::SSpecInfo> _infos);
181+
182+
struct CShaderStages
183+
{
184+
const CStageIntrospectionData* vertex = nullptr;
185+
const CStageIntrospectionData* fragment = nullptr;
186+
const CStageIntrospectionData* control = nullptr;
187+
const CStageIntrospectionData* evaluation = nullptr;
188+
const CStageIntrospectionData* geometry = nullptr;
189+
}
190+
core::smart_refctd_ptr<ICPUGraphicsPipeline> createApproximateGraphicsPipeline(const CShaderStages& shaderStages);
183191

184192
private:
185-
using mapId2SpecConst_t = core::unordered_map<uint32_t, const CIntrospectionData::SSpecConstant*>;
193+
//TODO: przenieϾ jako members do CIntrospectionData
194+
core::smart_refctd_dynamic_array<SPushConstantRange> createPushConstantRangesFromIntrospection_impl();
195+
core::smart_refctd_ptr<ICPUDescriptorSetLayout> createApproximateDescriptorSetLayoutFromIntrospection_impl(const uint32_t setID);
196+
core::smart_refctd_ptr<ICPUPipelineLayout> createApproximatePipelineLayoutFromIntrospection_impl();
186197

187-
core::smart_refctd_dynamic_array<SPushConstantRange> createPushConstantRangesFromIntrospection_impl(core::smart_refctd_ptr<const CIntrospectionData>* const introspections, const std::span<const ICPUShader::SSpecInfo> shaders);
188-
core::smart_refctd_ptr<ICPUDescriptorSetLayout> createApproximateDescriptorSetLayoutFromIntrospection_impl(uint32_t _set, core::smart_refctd_ptr<const CIntrospectionData>* const introspections, const std::span<const ICPUShader::SSpecInfo> shaders);
189-
core::smart_refctd_ptr<ICPUPipelineLayout> createApproximatePipelineLayoutFromIntrospection_impl(core::smart_refctd_ptr<const CIntrospectionData>* const introspections, const std::span<const ICPUShader::SSpecInfo> shaders);
190-
191-
bool introspectAllShaders(core::smart_refctd_ptr<const CIntrospectionData>* introspection, const std::span<const ICPUShader::SSpecInfo> _infos);
198+
core::smart_refctd_ptr<CStageIntrospectionData> introspectShader(const ICPUShader::SSpecInfo _infos);
192199

193200
core::smart_refctd_ptr<const CIntrospectionData> doIntrospection(spirv_cross::Compiler& _comp, const std::string& entryPoint, const IShader::E_SHADER_STAGE stage) const;
194201
void shaderMemBlockIntrospection(spirv_cross::Compiler& _comp, impl::SShaderMemoryBlock& _res, uint32_t _blockBaseTypeID, uint32_t _varID, const mapId2SpecConst_t& _sortedId2sconst) const;
@@ -213,9 +220,11 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable
213220
};
214221

215222
using ParamsToDataMap = core::unordered_map<SIntrospectionParams,core::smart_refctd_ptr<const CIntrospectionData>, KeyHasher>;
223+
// using ParamsToDataMap = core::unordered_set<core::smart_refctd_ptr<const CStageIntrospectionData>, KeyHasher, KeyEquals>;
216224
ParamsToDataMap m_introspectionCache;
217225
};
218226

219227
} // nbl::asset
220228

221229
#endif
230+
#endif

include/nbl/video/ILogicalDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
8585
bool supportsMask(const uint32_t queueFamilyIndex, core::bitflag<asset::ACCESS_FLAGS> accessMask) const;
8686

8787
//! NOTE/TODO: this is not yet finished
88-
inline bool validateMemoryBarrier(const uint32_t queueFamilyIndex, asset::SMemoryBarrier barrier) const;
88+
bool validateMemoryBarrier(const uint32_t queueFamilyIndex, asset::SMemoryBarrier barrier) const;
8989
inline bool validateMemoryBarrier(const uint32_t queueFamilyIndex, const IGPUCommandBuffer::SOwnershipTransferBarrier& barrier, const bool concurrentSharing) const
9090
{
9191
// implicitly satisfied by our API:

include/nbl/video/IPhysicalDevice.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,11 @@ class NBL_API2 IPhysicalDevice : public core::Interface, public core::Unmovable
559559
if (videoDecodeDPB && !other.videoDecodeDPB) return false;
560560
if (videoEncodeInput && !other.videoEncodeInput) return false;
561561
if (videoEncodeDPB && !other.videoEncodeDPB) return false;
562-
if (other.storageImageLoadWithoutFormat && !storageImageLoadWithoutFormat) return false;
563-
if (other.storageImageStoreWithoutFormat && !storageImageStoreWithoutFormat) return false;
564-
if (other.depthCompareSampledImage && !depthCompareSampledImage) return false;
565-
if (other.hostImageTransfer && !hostImageTransfer) return false;
566-
if (other.log2MaxSamples < log2MaxSamples) return false;
562+
if (storageImageLoadWithoutFormat && !other.storageImageLoadWithoutFormat) return false;
563+
if (storageImageStoreWithoutFormat && !other.storageImageStoreWithoutFormat) return false;
564+
if (depthCompareSampledImage && !other.depthCompareSampledImage) return false;
565+
if (hostImageTransfer && !other.hostImageTransfer) return false;
566+
if (log2MaxSamples > other.log2MaxSamples) return false;
567567
return true;
568568
}
569569

src/nbl/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,13 @@ include(common)
8383

8484
#[[ Loaders and writers compile options available to edit by user
8585
All revelant _NBL_COMPILE_WITH will be there]]
86-
option(_NBL_COMPILE_WITH_MTL_LOADER_ "Compile with MTL Loader" ON)
87-
option(_NBL_COMPILE_WITH_OBJ_LOADER_ "Compile with OBJ Loader" ON)
86+
option(_NBL_COMPILE_WITH_MTL_LOADER_ "Compile with MTL Loader" OFF) #default off until Material Compiler 2
87+
option(_NBL_COMPILE_WITH_OBJ_LOADER_ "Compile with OBJ Loader" OFF) #default off until Material Compiler 2
8888
#option(_NBL_COMPILE_WITH_OBJ_WRITER_ "Compile with OBJ Writer" ON) uncomment when writer exists
89-
option(_NBL_COMPILE_WITH_STL_LOADER_ "Compile with STL Loader" ON)
89+
option(_NBL_COMPILE_WITH_STL_LOADER_ "Compile with STL Loader" OFF) #default off until Material Compiler 2
9090
option(_NBL_COMPILE_WITH_STL_WRITER_ "Compile with STL Writer" ON)
91-
option(_NBL_COMPILE_WITH_PLY_LOADER_ "Compile with PLY Loader" ON)
91+
option(_NBL_COMPILE_WITH_PLY_LOADER_ "Compile with PLY Loader" OFF) #default off until Material Compiler 2
9292
option(_NBL_COMPILE_WITH_PLY_WRITER_ "Compile with PLY Writer" ON)
93-
option(_NBL_COMPILE_WITH_BAW_LOADER_ "Compile with BAW Loader" OFF)
94-
option(_NBL_COMPILE_WITH_BAW_WRITER_ "Compile with BAW Writer" OFF)
9593
option(_NBL_COMPILE_WITH_JPG_LOADER_ "Compile with JPG Loader" ON)
9694
option(_NBL_COMPILE_WITH_JPG_WRITER_ "Compile with JPG Writer" ON)
9795
option(_NBL_COMPILE_WITH_PNG_LOADER_ "Compile with PNG Loader" ON)

src/nbl/asset/utils/CSPIRVIntrospector.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (C) 2018-2024 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#if 0
45
#include "nbl/asset/utils/CSPIRVIntrospector.h"
56
#include "nbl/asset/utils/spvUtils.h"
67

@@ -798,3 +799,5 @@ CSPIRVIntrospector::CIntrospectionData::~CIntrospectionData()
798799

799800

800801
} // nbl:asset
802+
803+
#endif

0 commit comments

Comments
 (0)