diff --git a/HPL2/resource/translucency.frag.fsl b/HPL2/resource/translucency.frag.fsl index 98b05fa21..1a689eac5 100644 --- a/HPL2/resource/translucency.frag.fsl +++ b/HPL2/resource/translucency.frag.fsl @@ -33,8 +33,6 @@ PsOut PS_MAIN(PsIn In) float4 finalColor = float4(0.0, 0.0 ,0.0, 1.0); if(HasDiffuse(textureConfig)) { finalColor = SampleTex2D(Get(diffuseMap), Get(materialSampler), In.uv) * In.color; - } else { - finalColor.a = SampleTex2D(Get(diffuseMap), Get(materialSampler), In.uv).a * In.color.a; } float finalAlpha = Get(sceneAlpha); diff --git a/HPL2/resource/translucency_particle.frag.fsl b/HPL2/resource/translucency_particle.frag.fsl index 60fb68e1f..e46c848a0 100644 --- a/HPL2/resource/translucency_particle.frag.fsl +++ b/HPL2/resource/translucency_particle.frag.fsl @@ -25,8 +25,6 @@ float4 PS_MAIN(PsIn In) if(HasDiffuse(textureConfig)) { finalColor = SampleTex2D(Get(diffuseMap), Get(materialSampler), In.uv) * In.color; - } else { - finalColor.a = SampleTex2D(Get(diffuseMap), Get(materialSampler), In.uv).a * In.color.a; } float finalAlpha = Get(sceneAlpha); diff --git a/HPL2/sources/graphics/ForgeHandles.cpp b/HPL2/sources/graphics/ForgeHandles.cpp index 8c1bf36cf..5f7e4d605 100644 --- a/HPL2/sources/graphics/ForgeHandles.cpp +++ b/HPL2/sources/graphics/ForgeHandles.cpp @@ -204,6 +204,9 @@ namespace hpl { } + #define MIP_REDUCE(s, mip) (max(1u, (uint32_t)((s) >> (mip)))) + + SharedTexture SharedTexture::LoadFromHPLBitmap(cBitmap& bitmap, const BitmapLoadOptions& options) { SharedTexture handle; SyncToken token = {}; @@ -238,32 +241,50 @@ namespace hpl { }); auto sourceImageFormat = FromHPLPixelFormat(bitmap.GetPixelFormat()); - uint32_t sourceRowStride; - if(!util_get_surface_info(desc.mWidth, desc.mHeight, sourceImageFormat, nullptr, &sourceRowStride, nullptr)) { - ASSERT(false && "Failed to get surface info"); - } - uint32_t srcElementStride = sourceRowStride / desc.mWidth; - auto isCompressed = TinyImageFormat_IsCompressed(desc.mFormat); for(uint32_t arrIndex = 0; arrIndex < desc.mArraySize; arrIndex++) { for(uint32_t mipLevel = 0; mipLevel < desc.mMipLevels; mipLevel++) { TextureUpdateDesc update = {handle.m_handle, mipLevel, arrIndex}; const auto& input = bitmap.GetData(arrIndex, mipLevel); - auto data = std::span(input->mpData, static_cast(input->mlSize)); + //auto data = std::span(input->mpData, static_cast(input->mlSize)); beginUpdateResource(&update); - uint32_t dstElementStride = update.mDstRowStride / desc.mWidth; + + uint32_t sourceRowStride; + uint32_t destRowStride; + if (!util_get_surface_info( + MIP_REDUCE(desc.mWidth, mipLevel), + MIP_REDUCE(desc.mHeight, mipLevel), + sourceImageFormat, + nullptr, + &sourceRowStride, + nullptr)) { + ASSERT(false && "Failed to get surface info"); + } + uint32_t srcElementStride = sourceRowStride / desc.mWidth; + + if (!util_get_surface_info( + MIP_REDUCE(desc.mWidth, mipLevel), + MIP_REDUCE(desc.mHeight, mipLevel), + desc.mFormat, + nullptr, + &destRowStride, + nullptr)) { + ASSERT(false && "Failed to get surface info"); + } + + uint32_t dstElementStride = destRowStride / desc.mWidth; - for (uint32_t z = 0; z < desc.mDepth; ++z) + for (size_t z = 0; z < desc.mDepth; ++z) { - uint8_t* dstData = update.pMappedData + update.mDstSliceStride * z; - auto srcData = data.begin() + update.mSrcSliceStride * z; + uint8_t* dstData = update.pMappedData + (update.mDstSliceStride * z); + auto srcData = input->mpData + update.mSrcSliceStride * z; for (uint32_t row = 0; row < update.mRowCount; ++row) { if(isCompressed) { - std::memcpy(dstData + row * update.mDstRowStride, &srcData[row * update.mSrcRowStride], update.mSrcRowStride); + std::memcpy(dstData + (row * update.mDstRowStride), srcData + (row * update.mSrcRowStride), update.mSrcRowStride); } else { for(uint32_t column = 0; column < desc.mWidth; column++) { - std::memset(dstData + row * update.mDstRowStride + column * dstElementStride, 0xff, dstElementStride); - std::memcpy(dstData + row * update.mDstRowStride + column * dstElementStride, &srcData[row * sourceRowStride + column * srcElementStride], std::min(dstElementStride, srcElementStride)); + std::memset(dstData + (row * update.mDstRowStride + column * dstElementStride), 0xff, dstElementStride); + std::memcpy(dstData + (row * update.mDstRowStride + column * dstElementStride), srcData + (row * sourceRowStride + column * srcElementStride), std::min(dstElementStride, srcElementStride)); } } } diff --git a/HPL2/sources/graphics/RendererDeferred.cpp b/HPL2/sources/graphics/RendererDeferred.cpp index 39353cb50..f4d400f26 100644 --- a/HPL2/sources/graphics/RendererDeferred.cpp +++ b/HPL2/sources/graphics/RendererDeferred.cpp @@ -2510,11 +2510,11 @@ namespace hpl { // for DirectX12 these frame descriptors are not used so its ommitied for the draw -#if defined(VULKAN) - if (frame.m_renderer->GetApi() == RENDERER_API_VULKAN) { +//#if defined(VULKAN) +// if (frame.m_renderer->GetApi() == RENDERER_API_VULKAN) { cmdBindDescriptorSet(cmd, frameDescriptorIndex, m_materialSet.m_frameSet[frame.m_frameIndex].m_handle); - } -#endif +// } +//#endif for (auto& illuminationItem : m_rendererList.GetRenderableItems(eRenderListType_Illumination)) { cMaterial* pMaterial = illuminationItem->GetMaterial(); iVertexBuffer* vertexBuffer = illuminationItem->GetVertexBuffer(); diff --git a/HPL2/sources/resources/TextureManager.cpp b/HPL2/sources/resources/TextureManager.cpp index 83fc3ae7a..66a82d8b1 100644 --- a/HPL2/sources/resources/TextureManager.cpp +++ b/HPL2/sources/resources/TextureManager.cpp @@ -129,7 +129,6 @@ namespace hpl { asName, [&abUseMipMaps](const tString& asName, const tWString& path, cBitmap* pBmp) -> Image* { - auto* resource = new Image(asName, path); SharedTexture::BitmapLoadOptions opts = {0}; opts.m_useMipmaps = abUseMipMaps;