Skip to content

Commit

Permalink
Merge branch 'main' into transient
Browse files Browse the repository at this point in the history
  • Loading branch information
mdagois authored Sep 10, 2024
2 parents 13bbf9a + 37c615e commit 8345715
Show file tree
Hide file tree
Showing 10 changed files with 446 additions and 21 deletions.
2 changes: 2 additions & 0 deletions NEW_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ for next branch cut* header.
appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).

## Release notes for next branch cut

- Add support for multi-layered render target with array textures.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ VkPipelineLayout VulkanPipelineLayoutCache::getLayout(
}

// build the push constant layout key
uint32_t pushConstantRangeCount = program->getPushConstantRangeCount();
auto const& pushConstantRanges = program->getPushConstantRanges();
uint32_t const pushConstantRangeCount = program->getPushConstantRangeCount();
auto const& pushConstantRanges = program->getPushConstantRanges();
if (pushConstantRangeCount > 0) {
assert_invariant(pushConstantRangeCount <= Program::SHADER_TYPE_COUNT);
for (uint8_t i = 0; i < pushConstantRangeCount; ++i) {
Expand All @@ -52,8 +52,8 @@ VkPipelineLayout VulkanPipelineLayoutCache::getLayout(
}
}

if (PipelineLayoutMap::iterator iter = mPipelineLayouts.find(key); iter != mPipelineLayouts.end()) {
PipelineLayoutCacheEntry& entry = iter.value();
if (auto iter = mPipelineLayouts.find(key); iter != mPipelineLayouts.end()) {
PipelineLayoutCacheEntry& entry = iter->second;
entry.lastUsed = mTimestamp++;
return entry.handle;
}
Expand Down
10 changes: 5 additions & 5 deletions filament/backend/src/vulkan/caching/VulkanPipelineLayoutCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <utils/Hash.h>

#include <tsl/robin_map.h>
#include <unordered_map>

namespace filament::backend {

Expand All @@ -36,8 +36,8 @@ class VulkanPipelineLayoutCache {
void terminate() noexcept;

struct PushConstantKey {
uint8_t stage;// We have one set of push constant per shader stage (fragment, vertex, etc).
uint8_t size;
uint8_t stage = 0;// We have one set of push constant per shader stage (fragment, vertex, etc).
uint8_t size = 0;
// Note that there is also an offset parameter for push constants, but
// we always assume our update range will have the offset 0.
};
Expand Down Expand Up @@ -73,7 +73,7 @@ class VulkanPipelineLayoutCache {
}
};

using PipelineLayoutMap = tsl::robin_map<PipelineLayoutKey, PipelineLayoutCacheEntry,
using PipelineLayoutMap = std::unordered_map<PipelineLayoutKey, PipelineLayoutCacheEntry,
PipelineLayoutKeyHashFn, PipelineLayoutKeyEqual>;

VkDevice mDevice;
Expand All @@ -82,6 +82,6 @@ class VulkanPipelineLayoutCache {
PipelineLayoutMap mPipelineLayouts;
};

}
} // filament::backend

#endif // TNT_FILAMENT_BACKEND_VULKANPIPELINECACHE_H
7 changes: 7 additions & 0 deletions filament/include/filament/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,13 @@ class UTILS_PUBLIC View : public FilamentAPI {
*/
void setShadowType(ShadowType shadow) noexcept;

/**
* Returns the shadow mapping technique used by this View.
*
* @return value set by setShadowType().
*/
ShadowType getShadowType() const noexcept;

/**
* Sets VSM shadowing options that apply across the entire View.
*
Expand Down
4 changes: 4 additions & 0 deletions filament/src/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ void View::setShadowType(View::ShadowType shadow) noexcept {
downcast(this)->setShadowType(shadow);
}

View::ShadowType View::getShadowType() const noexcept {
return downcast(this)->getShadowType();
}

void View::setVsmShadowOptions(VsmShadowOptions const& options) noexcept {
downcast(this)->setVsmShadowOptions(options);
}
Expand Down
12 changes: 9 additions & 3 deletions filament/src/details/RenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct RenderTarget::BuilderDetails {
uint32_t mWidth{};
uint32_t mHeight{};
uint8_t mSamples = 1; // currently not settable in the public facing API
uint8_t mLayerCount = 0;// currently not settable in the public facing API
uint8_t mLayerCount = 1;
};

using BuilderType = RenderTarget;
Expand Down Expand Up @@ -91,22 +91,28 @@ RenderTarget* RenderTarget::Builder::build(Engine& engine) {
uint32_t maxWidth = 0;
uint32_t minHeight = std::numeric_limits<uint32_t>::max();
uint32_t maxHeight = 0;
uint32_t minDepth = std::numeric_limits<uint32_t>::max();
uint32_t maxDepth = 0;
for (auto const& attachment : mImpl->mAttachments) {
if (attachment.texture) {
const uint32_t w = attachment.texture->getWidth(attachment.mipLevel);
const uint32_t h = attachment.texture->getHeight(attachment.mipLevel);
const uint32_t d = attachment.texture->getDepth(attachment.mipLevel);
minWidth = std::min(minWidth, w);
minHeight = std::min(minHeight, h);
minDepth = std::min(minDepth, d);
maxWidth = std::max(maxWidth, w);
maxHeight = std::max(maxHeight, h);
maxDepth = std::max(maxDepth, d);
}
}

FILAMENT_CHECK_PRECONDITION(minWidth == maxWidth && minHeight == maxHeight)
<< "All attachments dimensions must match";
FILAMENT_CHECK_PRECONDITION(minWidth == maxWidth && minHeight == maxHeight
&& minDepth == maxDepth) << "All attachments dimensions must match";

mImpl->mWidth = minWidth;
mImpl->mHeight = minHeight;
mImpl->mLayerCount = minDepth;
return downcast(engine).createRenderTarget(*this);
}

Expand Down
16 changes: 7 additions & 9 deletions libs/filamat/src/GLSLPostProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,13 @@ void GLSLPostProcessor::fixupClipDistance(
// - triggers a crash on some Adreno drivers (b/291140208, b/289401984, b/289393290)
// However Metal requires this pass in order to correctly generate half-precision MSL
//
// Note: CreateSimplificationPass() used to creates a lot of problems:
// CreateSimplificationPass() creates a lot of problems:
// - Adreno GPU show artifacts after running simplification passes (Vulkan)
// - spirv-cross fails generating working glsl
// (https://github.com/KhronosGroup/SPIRV-Cross/issues/2162)
//
// However this problem was addressed in spirv-cross here:
// https://github.com/KhronosGroup/SPIRV-Cross/pull/2163
//
// The simplification passes below are necessary when targeting Metal, otherwise the
// - generally it makes the code more complicated, e.g.: replacing for loops with
// while-if-break, unclear if it helps for anything.
// However, the simplification passes below are necessary when targeting Metal, otherwise the
// result is mismatched half / float assignments in MSL.


Expand Down Expand Up @@ -712,11 +710,11 @@ void GLSLPostProcessor::registerPerformancePasses(Optimizer& optimizer, Config c
RegisterPass(CreateAggressiveDCEPass());
RegisterPass(CreateRedundancyEliminationPass());
RegisterPass(CreateCombineAccessChainsPass());
RegisterPass(CreateSimplificationPass());
RegisterPass(CreateSimplificationPass(), MaterialBuilder::TargetApi::METAL);
RegisterPass(CreateVectorDCEPass());
RegisterPass(CreateDeadInsertElimPass());
RegisterPass(CreateDeadBranchElimPass());
RegisterPass(CreateSimplificationPass());
RegisterPass(CreateSimplificationPass(), MaterialBuilder::TargetApi::METAL);
RegisterPass(CreateIfConversionPass());
RegisterPass(CreateCopyPropagateArraysPass());
RegisterPass(CreateReduceLoadSizePass());
Expand All @@ -725,7 +723,7 @@ void GLSLPostProcessor::registerPerformancePasses(Optimizer& optimizer, Config c
RegisterPass(CreateRedundancyEliminationPass());
RegisterPass(CreateDeadBranchElimPass());
RegisterPass(CreateBlockMergePass());
RegisterPass(CreateSimplificationPass());
RegisterPass(CreateSimplificationPass(), MaterialBuilder::TargetApi::METAL);
}

void GLSLPostProcessor::registerSizePasses(Optimizer& optimizer, Config const& config) {
Expand Down
3 changes: 3 additions & 0 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(MATERIAL_SRCS
materials/bakedTexture.mat
materials/pointSprites.mat
materials/aoPreview.mat
materials/arrayTexture.mat
materials/groundShadow.mat
materials/heightfield.mat
materials/image.mat
Expand Down Expand Up @@ -252,6 +253,7 @@ if (NOT ANDROID)
add_demo(helloskinning)
add_demo(helloskinningbuffer)
add_demo(helloskinningbuffer_morebones)
add_demo(hellostereo)
add_demo(image_viewer)
add_demo(lightbulb)
add_demo(material_sandbox)
Expand All @@ -274,6 +276,7 @@ if (NOT ANDROID)
target_link_libraries(gltf_viewer PRIVATE gltf-demo-resources uberarchive gltfio viewer)
target_link_libraries(gltf_instances PRIVATE gltf-demo-resources uberarchive gltfio viewer)
target_link_libraries(hellopbr PRIVATE filameshio suzanne-resources)
target_link_libraries(hellostereo PRIVATE filameshio suzanne-resources)
target_link_libraries(image_viewer PRIVATE viewer imageio)
target_link_libraries(multiple_windows PRIVATE filameshio suzanne-resources)
target_link_libraries(rendertarget PRIVATE filameshio suzanne-resources)
Expand Down
Loading

0 comments on commit 8345715

Please sign in to comment.