Skip to content

Commit

Permalink
API fixes => example 5 works again
Browse files Browse the repository at this point in the history
  • Loading branch information
devshgraphicsprogramming committed Dec 9, 2019
1 parent 77b1edd commit 42347d2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
18 changes: 8 additions & 10 deletions examples_tests/05.SpherePoints/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main()
return driver->getGPUObjectsFromAssets(&cpuSS,&cpuSS+1u)->operator[](0);
};

SPushConstantRange range[1] = {ESS_VERTEX,0u,sizeof(core::matrix4SIMD)};
SPushConstantRange range[1] = {asset::ISpecializedShader::ESS_VERTEX,0u,sizeof(core::matrix4SIMD)};
auto pLayout = driver->createGPUPipelineLayout(range,range+1u,nullptr,nullptr,nullptr,nullptr);

core::smart_refctd_ptr<IGPUSpecializedShader> shaders[2] = {loadShader("../points.vert"),loadShader("../points.frag")};
Expand All @@ -65,17 +65,15 @@ int main()
inputParams.bindings[0].stride = sizeof(uint32_t);
inputParams.bindings[0].inputRate = EVIR_PER_VERTEX;

SBlendParams blendParams;
blendParams.logicOpEnable = false;
blendParams.logicOp = ELO_NO_OP;
for (size_t i=0ull; i<SBlendParams::MAX_COLOR_ATTACHMENT_COUNT; i++)
blendParams.blendParams[i] = {i==0ull,false,EBF_ONE,EBF_ZERO,EBO_ADD,EBF_ONE,EBF_ZERO,EBO_ADD,0xfu};
SBlendParams blendParams; // default

SPrimitiveAssemblyParams assemblyParams = {EPT_POINT_LIST,false,1u};

SStencilOpParams defaultStencil;
SRasterizationParams rasterParams = {1u,EPM_FILL,EFCM_NONE,ECO_ALWAYS,IImage::ESCF_1_BIT,{~0u,~0u},1.f,0.f,0.f,defaultStencil,defaultStencil,
{false,false,true,false,false,false,false,false,false,false,false}};
SRasterizationParams rasterParams;
rasterParams.faceCullingMode = EFCM_NONE;
rasterParams.depthCompareOp = ECO_ALWAYS;
rasterParams.depthTestEnable = false;
rasterParams.depthWriteEnable = false;

auto pipeline = driver->createGPURenderpassIndependentPipeline( nullptr,std::move(pLayout),shadersPtr,shadersPtr+sizeof(shaders)/sizeof(core::smart_refctd_ptr<IGPUSpecializedShader>),
inputParams,blendParams,assemblyParams,rasterParams);
Expand Down Expand Up @@ -121,7 +119,7 @@ int main()
core::matrix4SIMD mvp = camera->getConcatenatedMatrix();

driver->bindGraphicsPipeline(pipeline.get());
driver->pushConstants(pipeline->getLayout(),ESS_VERTEX,0u,sizeof(core::matrix4SIMD),mvp.pointer());
driver->pushConstants(pipeline->getLayout(),asset::ISpecializedShader::ESS_VERTEX,0u,sizeof(core::matrix4SIMD),mvp.pointer());
driver->drawMeshBuffer(mb.get());

driver->endScene();
Expand Down
4 changes: 3 additions & 1 deletion include/irr/asset/IAssetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ class IAssetManager : public core::IReferenceCounted
}
auto res = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<SAssetBundle> >(reqSz);
findAssets(reqSz, res->data(), _key, _types);
return res;
auto retval = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<SAssetBundle> >(reqSz);
memcpy(retval->data(),res->data(),reqSz);
return retval;
}

//! It injects metadata into Asset structure
Expand Down
2 changes: 1 addition & 1 deletion include/irr/asset/ICPUDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ICPUDescriptorSet final : public IDescriptorSet<ICPUDescriptorSetLayout>,
break;
case IDescriptor::EC_IMAGE:
static_cast<asset::ICPUImageView*>(descriptor)->convertToDummyObject(referenceLevelsBelowToConvert);
if (descriptor->getTypeCategory()==IDescriptor::EC_IMAGE)
if (descriptor->getTypeCategory()==IDescriptor::EC_IMAGE && it->image.sampler)
it->image.sampler->convertToDummyObject(referenceLevelsBelowToConvert);
break;
case IDescriptor::EC_BUFFER_VIEW:
Expand Down
1 change: 1 addition & 0 deletions include/irr/asset/ICPUImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ICPUImage final : public IImage, public IAsset
inline void convertToDummyObject(uint32_t referenceLevelsBelowToConvert=0u) override
{
if (referenceLevelsBelowToConvert--)
if (buffer)
buffer->convertToDummyObject(referenceLevelsBelowToConvert);
regions = nullptr;
}
Expand Down
8 changes: 6 additions & 2 deletions include/irr/video/IGPUObjectFromAssetConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ class IGPUObjectFromAssetConverter
auto gpu = m_assetManager->findGPUObject(get_asset_raw_ptr<AssetType, iterator_type>::value(it));
if (!gpu)
{
notFound.push_back(get_asset_raw_ptr<AssetType,iterator_type>::value(it));
if ((*it)->isADummyObjectForCache())
notFound.push_back(nullptr);
else
notFound.push_back(get_asset_raw_ptr<AssetType,iterator_type>::value(it));
pos.push_back(index);
}
else
Expand All @@ -90,7 +93,8 @@ class IGPUObjectFromAssetConverter
for (size_t i=0u; i<created->size(); ++i)
{
auto& input = created->operator[](i);
m_assetManager->convertAssetToEmptyCacheHandle(notFound[i], core::smart_refctd_ptr(input));
if (notFound[i])
m_assetManager->convertAssetToEmptyCacheHandle(notFound[i], core::smart_refctd_ptr(input));
res->operator[](pos[i]) = std::move(input); // ok to move because the `created` array will die after the next scope
}
}
Expand Down

0 comments on commit 42347d2

Please sign in to comment.