Fix static analysis warnings
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@@ -150,7 +150,7 @@ KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, const KR
|
||||
|
||||
VkVertexInputBindingDescription bindingDescription{};
|
||||
bindingDescription.binding = 0;
|
||||
bindingDescription.stride = KRMesh::VertexSizeForAttributes(vertexAttributes);
|
||||
bindingDescription.stride = (uint32_t)KRMesh::VertexSizeForAttributes(vertexAttributes);
|
||||
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
|
||||
uint32_t vertexAttributeCount = 0;
|
||||
@@ -164,7 +164,7 @@ KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, const KR
|
||||
desc.binding = 0;
|
||||
desc.location = attribute_locations[location_attrib] - 1;
|
||||
desc.format = KRMesh::AttributeVulkanFormat(mesh_attrib);
|
||||
desc.offset = KRMesh::AttributeOffset(mesh_attrib, vertexAttributes);
|
||||
desc.offset = (uint32_t)KRMesh::AttributeOffset(mesh_attrib, vertexAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,8 +533,9 @@ bool KRPipeline::hasPushConstant(ShaderValue location) const
|
||||
}
|
||||
|
||||
|
||||
void KRPipeline::setPushConstants(const std::vector<const KRReflectedObject*> objects)
|
||||
bool KRPipeline::setPushConstants(const std::vector<const KRReflectedObject*> objects)
|
||||
{
|
||||
bool success = true;
|
||||
for (StageInfo& stageInfo : m_stages) {
|
||||
PushConstantInfo& pushConstants = stageInfo.pushConstants;
|
||||
for (int i = 0; i < kPushConstantCount; i++) {
|
||||
@@ -549,11 +550,13 @@ void KRPipeline::setPushConstants(const std::vector<const KRReflectedObject*> ob
|
||||
}
|
||||
}
|
||||
if(!found) {
|
||||
success = false;
|
||||
KRContext::Log(KRContext::LOG_LEVEL_ERROR, "Push constant not found: %s", getShaderValueName(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void KRPipeline::setPushConstant(ShaderValue location, float value)
|
||||
@@ -637,7 +640,7 @@ void KRPipeline::updateDescriptorBinding()
|
||||
// Vulkan Refactoring
|
||||
}
|
||||
|
||||
void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matModel)
|
||||
bool KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matModel)
|
||||
{
|
||||
KRDirectionalLight* directionalLight = nullptr;
|
||||
if (ri.renderPass->getType() != RenderPassType::RENDER_PASS_DEFERRED_LIGHTS && ri.renderPass->getType() != RenderPassType::RENDER_PASS_DEFERRED_GBUFFER && ri.renderPass->getType() != RenderPassType::RENDER_PASS_DEFERRED_OPAQUE && ri.renderPass->getType() != RenderPassType::RENDER_PASS_SHADOWMAP) {
|
||||
@@ -653,7 +656,7 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM
|
||||
ri.reflectedObjects.push_back(ri.viewport);
|
||||
ri.reflectedObjects.push_back(&ri.camera->settings);
|
||||
|
||||
setPushConstants(ri.reflectedObjects);
|
||||
bool success = setPushConstants(ri.reflectedObjects);
|
||||
|
||||
ri.reflectedObjects.pop_back();
|
||||
ri.reflectedObjects.pop_back();
|
||||
@@ -661,12 +664,18 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM
|
||||
|
||||
setPushConstant(ShaderValue::absolute_time, getContext().getAbsoluteTime());
|
||||
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (StageInfo& stageInfo : m_stages) {
|
||||
PushConstantInfo& pushConstants = stageInfo.pushConstants;
|
||||
if (pushConstants.buffer) {
|
||||
vkCmdPushConstants(ri.commandBuffer, pushConstants.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, pushConstants.bufferSize, pushConstants.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KRPipeline::bind(KRNode::RenderInfo& ri, const Matrix4& matModel)
|
||||
@@ -674,7 +683,9 @@ bool KRPipeline::bind(KRNode::RenderInfo& ri, const Matrix4& matModel)
|
||||
updateDescriptorBinding();
|
||||
updateDescriptorSets();
|
||||
bindDescriptorSets(ri.commandBuffer);
|
||||
updatePushConstants(ri, matModel);
|
||||
if (!updatePushConstants(ri, matModel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ri.pipeline != this) {
|
||||
vkCmdBindPipeline(ri.commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_graphicsPipeline);
|
||||
|
||||
@@ -221,7 +221,7 @@ public:
|
||||
|
||||
static const size_t kPushConstantCount = static_cast<size_t>(ShaderValue::NUM_SHADER_VALUES);
|
||||
|
||||
void setPushConstants(const std::vector<const KRReflectedObject*> objects);
|
||||
bool setPushConstants(const std::vector<const KRReflectedObject*> objects);
|
||||
bool hasPushConstant(ShaderValue location) const;
|
||||
void setPushConstant(ShaderValue location, float value);
|
||||
void setPushConstant(ShaderValue location, int value);
|
||||
@@ -239,7 +239,7 @@ public:
|
||||
private:
|
||||
void updateDescriptorBinding();
|
||||
void updateDescriptorSets();
|
||||
void updatePushConstants(KRNode::RenderInfo& ri, const hydra::Matrix4& matModel);
|
||||
bool updatePushConstants(KRNode::RenderInfo& ri, const hydra::Matrix4& matModel);
|
||||
|
||||
struct PushConstantInfo
|
||||
{
|
||||
|
||||
@@ -166,7 +166,9 @@ void KRNode::makeOrphan()
|
||||
KRNode::~KRNode()
|
||||
{
|
||||
while (m_firstChildNode != nullptr) {
|
||||
KRNode* nextChild = m_firstChildNode->m_nextNode;
|
||||
delete m_firstChildNode;
|
||||
m_firstChildNode = nextChild;
|
||||
}
|
||||
|
||||
makeOrphan();
|
||||
|
||||
@@ -743,14 +743,13 @@ kraken_stream_level KRMaterial::getStreamLevel()
|
||||
return stream_level;
|
||||
}
|
||||
|
||||
void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_t vertexAttributes, CullMode cullMode, const std::vector<KRBone*>& bones, const std::vector<Matrix4>& bind_poses, const Matrix4& matModel, KRTexture* pLightMap, float lod_coverage)
|
||||
bool KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_t vertexAttributes, CullMode cullMode, const std::vector<KRBone*>& bones, const std::vector<Matrix4>& bind_poses, const Matrix4& matModel, KRTexture* pLightMap, float lod_coverage)
|
||||
{
|
||||
bool bLightMap = pLightMap && ri.camera->settings.bEnableLightMap;
|
||||
|
||||
Vector2 default_scale = Vector2::One();
|
||||
Vector2 default_offset = Vector2::Zero();
|
||||
|
||||
bool bHasReflection = m_roughnessFactor > 0.f;
|
||||
bool bDiffuseMap = m_baseColorMap.texture.isBound() && ri.camera->settings.bEnableDiffuseMap;
|
||||
bool bNormalMap = m_normalMap.texture.isBound() && ri.camera->settings.bEnableNormalMap;
|
||||
bool bSpecMap = false;
|
||||
@@ -845,9 +844,13 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
|
||||
// pShader->setImageBinding("reflectionTexture", m_reflection.texture.get(), getContext().getSamplerManager()->DEFAULT_CLAMPED_SAMPLER);
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
ri.reflectedObjects.push_back(this);
|
||||
pShader->bind(ri, matModel);
|
||||
if (!pShader->bind(ri, matModel)) {
|
||||
success = false;
|
||||
}
|
||||
ri.reflectedObjects.pop_back();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool KRMaterial::getShaderValue(ShaderValue value, float* output) const
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
|
||||
bool isTransparent();
|
||||
|
||||
void bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_t vertexAttributes, CullMode cullMode, const std::vector<KRBone*>& bones, const std::vector<hydra::Matrix4>& bind_poses, const hydra::Matrix4& matModel, KRTexture* pLightMap, float lod_coverage = 0.0f);
|
||||
bool bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_t vertexAttributes, CullMode cullMode, const std::vector<KRBone*>& bones, const std::vector<hydra::Matrix4>& bind_poses, const hydra::Matrix4& matModel, KRTexture* pLightMap, float lod_coverage = 0.0f);
|
||||
|
||||
bool needsVertexTangents();
|
||||
|
||||
|
||||
@@ -266,21 +266,27 @@ void KRMesh::render(KRNode::RenderInfo& ri, const std::string& object_name, cons
|
||||
switch (pMaterial->getAlphaMode()) {
|
||||
case KRMaterial::KRMATERIAL_ALPHA_MODE_OPAQUE: // Non-transparent materials
|
||||
case KRMaterial::KRMATERIAL_ALPHA_MODE_TEST: // Alpha in diffuse texture is interpreted as punch-through when < 0.5
|
||||
pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullBack, bones, bone_bind_poses, matModel, pLightMap, lod_coverage);
|
||||
if (pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullBack, bones, bone_bind_poses, matModel, pLightMap, lod_coverage))
|
||||
{
|
||||
renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage);
|
||||
}
|
||||
break;
|
||||
case KRMaterial::KRMATERIAL_ALPHA_MODE_BLEND: // Blended Alpha
|
||||
if (pMaterial->m_doubleSided) {
|
||||
// Blended alpha rendered in two passes. First pass renders backfaces; second pass renders frontfaces.
|
||||
//
|
||||
// Render back faces before front faces
|
||||
pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullFront, bones, bone_bind_poses, matModel, pLightMap, lod_coverage);
|
||||
if (pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullFront, bones, bone_bind_poses, matModel, pLightMap, lod_coverage))
|
||||
{
|
||||
renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage);
|
||||
}
|
||||
}
|
||||
|
||||
// Render front faces
|
||||
pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullBack, bones, bone_bind_poses, matModel, pLightMap, lod_coverage);
|
||||
if (pMaterial->bind(ri, getModelFormat(), getVertexAttributes(), CullMode::kCullBack, bones, bone_bind_poses, matModel, pLightMap, lod_coverage))
|
||||
{
|
||||
renderSubmesh(ri.commandBuffer, iSubmesh, ri.renderPass, object_name, pMaterial->getName(), lod_coverage);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ bool KRShaderManager::compileAll(KRBundle* outputBundle, KRUnknown* logResource)
|
||||
}
|
||||
sourceName = source->getName() + "." + source->getExtension();
|
||||
sourceText[0] = (char*)source->getData()->getStart();
|
||||
sourceLen[0] = source->getData()->getSize();
|
||||
sourceLen[0] = (int)source->getData()->getSize();
|
||||
sourceNameStr[0] = sourceName.c_str();
|
||||
shader.setStringsWithLengthsAndNames(sourceText, sourceLen, sourceNameStr, 1);
|
||||
//shader.setStrings(&sourceStr, 1);
|
||||
|
||||
@@ -57,7 +57,7 @@ bool KRTexture2D::createGPUTexture(int targetLod)
|
||||
void* buffer = malloc(bufferSize);
|
||||
|
||||
if (!getLodData(buffer, targetLod)) {
|
||||
delete buffer;
|
||||
free(buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ bool KRTexture2D::createGPUTexture(int targetLod)
|
||||
device.streamUpload((void*)buffer, bufferSize, texture.image, regions.data(), regions.size());
|
||||
}
|
||||
|
||||
delete buffer;
|
||||
free(buffer);
|
||||
|
||||
if (success) {
|
||||
m_new_lod = targetLod;
|
||||
|
||||
@@ -152,7 +152,8 @@ bool KRTextureCube::createGPUTexture(int lod)
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (buffers[i]) {
|
||||
delete buffers[i];
|
||||
free(buffers[i]);
|
||||
buffers[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,6 @@ bool KRTextureTGA::getLodData(void* buffer, int lod)
|
||||
return false; // Mapped colors not supported
|
||||
}
|
||||
|
||||
Vector3i dimensions = { pHeader->width, pHeader->height, 1 };
|
||||
|
||||
switch (pHeader->imagetype) {
|
||||
case 2: // rgb
|
||||
switch (pHeader->bitsperpixel) {
|
||||
|
||||
Reference in New Issue
Block a user