Merge remote-tracking branch 'upstream/development' into Atom/santorac/RemixableMaterialTypes4_Layering
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
@@ -434,5 +434,29 @@ namespace AZ
|
||||
return m_renderTick;
|
||||
}
|
||||
|
||||
void RPISystem::SetApplicationMultisampleState(const RHI::MultisampleState& multisampleState)
|
||||
{
|
||||
m_multisampleState = multisampleState;
|
||||
|
||||
bool isNonMsaaPipeline = (m_multisampleState.m_samples == 1);
|
||||
const char* supervariantName = isNonMsaaPipeline ? AZ::RPI::NoMsaaSupervariantName : "";
|
||||
AZ::RPI::ShaderSystemInterface::Get()->SetSupervariantName(AZ::Name(supervariantName));
|
||||
|
||||
// reinitialize pipelines for all scenes
|
||||
for (auto& scene : m_scenes)
|
||||
{
|
||||
for (auto& renderPipeline : scene->GetRenderPipelines())
|
||||
{
|
||||
renderPipeline->GetRenderSettings().m_multisampleState = multisampleState;
|
||||
renderPipeline->SetPassNeedsRecreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const RHI::MultisampleState& RPISystem::GetApplicationMultisampleState() const
|
||||
{
|
||||
return m_multisampleState;
|
||||
}
|
||||
|
||||
} //namespace RPI
|
||||
} //namespace AZ
|
||||
|
||||
@@ -232,16 +232,12 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T GetSubImagePixelValueInternal(const AZ::Data::Asset<AZ::RPI::StreamingImageAsset>& imageAsset, uint32_t x, uint32_t y, uint32_t componentIndex, uint32_t mip, uint32_t slice)
|
||||
size_t GetImageDataIndex(const AZ::RHI::ImageDescriptor& imageDescriptor, uint32_t x, uint32_t y, uint32_t componentIndex)
|
||||
{
|
||||
AZStd::array values{ aznumeric_cast<T>(0) };
|
||||
auto width = imageDescriptor.m_size.m_width;
|
||||
const uint32_t numComponents = AZ::RHI::GetFormatComponentCount(imageDescriptor.m_format);
|
||||
|
||||
auto topLeft = AZStd::make_pair(x, y);
|
||||
auto bottomRight = AZStd::make_pair(x + 1, y + 1);
|
||||
GetSubImagePixelValues(imageAsset, topLeft, bottomRight, AZStd::span<T>(values), componentIndex, mip, slice);
|
||||
|
||||
return values[0];
|
||||
return (y * width + x) * numComponents + componentIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,22 +443,60 @@ namespace AZ
|
||||
return GetComputeShaderNumThreads(shaderAsset, &dispatchDirect.m_threadsPerGroupX, &dispatchDirect.m_threadsPerGroupY, &dispatchDirect.m_threadsPerGroupZ);
|
||||
}
|
||||
|
||||
template<>
|
||||
float GetImageDataPixelValue<float>(AZStd::span<const uint8_t> imageData, const AZ::RHI::ImageDescriptor& imageDescriptor, uint32_t x, uint32_t y, uint32_t componentIndex)
|
||||
{
|
||||
size_t imageDataIndex = Internal::GetImageDataIndex(imageDescriptor, x, y, componentIndex);
|
||||
return Internal::RetrieveFloatValue(imageData.data(), imageDataIndex, imageDescriptor.m_format);
|
||||
}
|
||||
|
||||
template<>
|
||||
AZ::u32 GetImageDataPixelValue<AZ::u32>(AZStd::span<const uint8_t> imageData, const AZ::RHI::ImageDescriptor& imageDescriptor, uint32_t x, uint32_t y, uint32_t componentIndex)
|
||||
{
|
||||
size_t imageDataIndex = Internal::GetImageDataIndex(imageDescriptor, x, y, componentIndex);
|
||||
return Internal::RetrieveUintValue(imageData.data(), imageDataIndex, imageDescriptor.m_format);
|
||||
}
|
||||
|
||||
template<>
|
||||
AZ::s32 GetImageDataPixelValue<AZ::s32>(AZStd::span<const uint8_t> imageData, const AZ::RHI::ImageDescriptor& imageDescriptor, uint32_t x, uint32_t y, uint32_t componentIndex)
|
||||
{
|
||||
size_t imageDataIndex = Internal::GetImageDataIndex(imageDescriptor, x, y, componentIndex);
|
||||
return Internal::RetrieveIntValue(imageData.data(), imageDataIndex, imageDescriptor.m_format);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T GetSubImagePixelValueInternal(const AZ::Data::Asset<AZ::RPI::StreamingImageAsset>& imageAsset, uint32_t x, uint32_t y, uint32_t componentIndex, uint32_t mip, uint32_t slice)
|
||||
{
|
||||
if (!imageAsset.IsReady())
|
||||
{
|
||||
return aznumeric_cast<T>(0);
|
||||
}
|
||||
|
||||
auto imageData = imageAsset->GetSubImageData(mip, slice);
|
||||
if (imageData.empty())
|
||||
{
|
||||
return aznumeric_cast<T>(0);
|
||||
}
|
||||
|
||||
return GetImageDataPixelValue<T>(imageData, imageAsset->GetImageDescriptor(), x, y, componentIndex);
|
||||
}
|
||||
|
||||
template<>
|
||||
float GetSubImagePixelValue<float>(const AZ::Data::Asset<AZ::RPI::StreamingImageAsset>& imageAsset, uint32_t x, uint32_t y, uint32_t componentIndex, uint32_t mip, uint32_t slice)
|
||||
{
|
||||
return Internal::GetSubImagePixelValueInternal<float>(imageAsset, x, y, componentIndex, mip, slice);
|
||||
return GetSubImagePixelValueInternal<float>(imageAsset, x, y, componentIndex, mip, slice);
|
||||
}
|
||||
|
||||
template<>
|
||||
AZ::u32 GetSubImagePixelValue<AZ::u32>(const AZ::Data::Asset<AZ::RPI::StreamingImageAsset>& imageAsset, uint32_t x, uint32_t y, uint32_t componentIndex, uint32_t mip, uint32_t slice)
|
||||
{
|
||||
return Internal::GetSubImagePixelValueInternal<AZ::u32>(imageAsset, x, y, componentIndex, mip, slice);
|
||||
return GetSubImagePixelValueInternal<AZ::u32>(imageAsset, x, y, componentIndex, mip, slice);
|
||||
}
|
||||
|
||||
template<>
|
||||
AZ::s32 GetSubImagePixelValue<AZ::s32>(const AZ::Data::Asset<AZ::RPI::StreamingImageAsset>& imageAsset, uint32_t x, uint32_t y, uint32_t componentIndex, uint32_t mip, uint32_t slice)
|
||||
{
|
||||
return Internal::GetSubImagePixelValueInternal<AZ::s32>(imageAsset, x, y, componentIndex, mip, slice);
|
||||
return GetSubImagePixelValueInternal<AZ::s32>(imageAsset, x, y, componentIndex, mip, slice);
|
||||
}
|
||||
|
||||
bool GetSubImagePixelValues(const AZ::Data::Asset<AZ::RPI::StreamingImageAsset>& imageAsset, AZStd::pair<uint32_t, uint32_t> topLeft, AZStd::pair<uint32_t, uint32_t> bottomRight, AZStd::span<float> outValues, uint32_t componentIndex, uint32_t mip, uint32_t slice)
|
||||
@@ -478,16 +512,14 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
const AZ::RHI::ImageDescriptor imageDescriptor = imageAsset->GetImageDescriptor();
|
||||
auto width = imageDescriptor.m_size.m_width;
|
||||
const uint32_t numComponents = AZ::RHI::GetFormatComponentCount(imageDescriptor.m_format);
|
||||
const AZ::RHI::ImageDescriptor& imageDescriptor = imageAsset->GetImageDescriptor();
|
||||
|
||||
size_t outValuesIndex = 0;
|
||||
for (uint32_t y = topLeft.second; y < bottomRight.second; ++y)
|
||||
{
|
||||
for (uint32_t x = topLeft.first; x < bottomRight.first; ++x)
|
||||
{
|
||||
size_t imageDataIndex = (y * width + x) * numComponents + componentIndex;
|
||||
size_t imageDataIndex = Internal::GetImageDataIndex(imageDescriptor, x, y, componentIndex);
|
||||
|
||||
auto& outValue = outValues[outValuesIndex++];
|
||||
outValue = Internal::RetrieveFloatValue(imageData.data(), imageDataIndex, imageDescriptor.m_format);
|
||||
@@ -510,16 +542,14 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
const AZ::RHI::ImageDescriptor imageDescriptor = imageAsset->GetImageDescriptor();
|
||||
auto width = imageDescriptor.m_size.m_width;
|
||||
const uint32_t numComponents = AZ::RHI::GetFormatComponentCount(imageDescriptor.m_format);
|
||||
const AZ::RHI::ImageDescriptor& imageDescriptor = imageAsset->GetImageDescriptor();
|
||||
|
||||
size_t outValuesIndex = 0;
|
||||
for (uint32_t y = topLeft.second; y < bottomRight.second; ++y)
|
||||
{
|
||||
for (uint32_t x = topLeft.first; x < bottomRight.first; ++x)
|
||||
{
|
||||
size_t imageDataIndex = (y * width + x) * numComponents + componentIndex;
|
||||
size_t imageDataIndex = Internal::GetImageDataIndex(imageDescriptor, x, y, componentIndex);
|
||||
|
||||
auto& outValue = outValues[outValuesIndex++];
|
||||
outValue = Internal::RetrieveUintValue(imageData.data(), imageDataIndex, imageDescriptor.m_format);
|
||||
@@ -542,16 +572,14 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
const AZ::RHI::ImageDescriptor imageDescriptor = imageAsset->GetImageDescriptor();
|
||||
auto width = imageDescriptor.m_size.m_width;
|
||||
const uint32_t numComponents = AZ::RHI::GetFormatComponentCount(imageDescriptor.m_format);
|
||||
const AZ::RHI::ImageDescriptor& imageDescriptor = imageAsset->GetImageDescriptor();
|
||||
|
||||
size_t outValuesIndex = 0;
|
||||
for (uint32_t y = topLeft.second; y < bottomRight.second; ++y)
|
||||
{
|
||||
for (uint32_t x = topLeft.first; x < bottomRight.first; ++x)
|
||||
{
|
||||
size_t imageDataIndex = (y * width + x) * numComponents + componentIndex;
|
||||
size_t imageDataIndex = Internal::GetImageDataIndex(imageDescriptor, x, y, componentIndex);
|
||||
|
||||
auto& outValue = outValues[outValuesIndex++];
|
||||
outValue = Internal::RetrieveIntValue(imageData.data(), imageDataIndex, imageDescriptor.m_format);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <AzCore/RTTI/ReflectContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -35,6 +36,15 @@ namespace AZ
|
||||
->Field("MaterialSlots", &ModelAsset::m_materialSlots)
|
||||
->Field("LodAssets", &ModelAsset::m_lodAssets)
|
||||
;
|
||||
|
||||
// Note: This class needs to have edit context reflection so PropertyAssetCtrl::OnEditButtonClicked
|
||||
// can open the asset with the preferred asset editor (Scene Settings).
|
||||
if (auto* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<ModelAsset>("Model Asset", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user