Skip to content

Commit

Permalink
Merge pull request #83 from bmwcarit/feature/oss-release-2023-01-26-0…
Browse files Browse the repository at this point in the history
…4-52

Oss release 27-0-130 created 2023-01-26-04-52
  • Loading branch information
violinyanev authored Jan 26, 2023
2 parents 0313843 + 5a8f24f commit 5963bf6
Show file tree
Hide file tree
Showing 148 changed files with 2,519 additions and 267 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@

27.0.130
-------------------
General changes
------------------------------------------------------------------------
- ramses-scene-viewer:
- fixed validation and "Used by" links for TextureSampler2DMS
- added "--gui only" command line parameter to only show the inspection gui, not the scene itself
- show GenerateMipChain flag for texture resources
- fixed CSV export for textures
- it is possible to assign the same ID to more than one texture consumer (check moved to validate())
- updated android demo projects to modern versions of the Android SDK and tools

API changes
------------------------------------------------------------------------
- Implemented native compositing on Android
- Added type TextureSamplerExternal on client side
- For GLSL version 100, use extension "GL_OES_EGL_image_external"
- For GLSL version 300 and later, use extension "GL_OES_EGL_image_external_essl3"
- Both extensions enable a new type of texture sampler in effects: samplerExternalOES
- For more info, refer to the corresponding OpenGL extensions documentation
- Added type externalBuffer_t on renderer side, with corresponding functions for creation, destruction and
events in RamsesRenderer and IRendererEventHandler
- Added texture linking for external buffers and TextureSamplerExternal
- Added Appearance::getInputTextureExternal()
- WARNING! Using this feature makes your scene incompatible to Ramses versions prior this one
- Make sure remote renderers have this version or newer if you use the feature in a distributed setup
- Added Appearance::getInputTextureMS()

Bugfixes
------------------------------------------------------------------------
- Fixed scene validation errors for TextureSamplerMS objects and related RenderBuffers.
RenderBuffers are no longer reported as unused when they are actually used by a TextureSamplerMS.
- Fixed Scene::resetUniformTimeMs() for local-only scenes.
Time reset was not applied to the shaders, if called before the scene was subscribed.
- X11: Fixed memory leak if DisplayConfig uses external X11-Window
- Fixed dlt buffer overflow for file transfer (e.g. scene dumps)

27.0.129
-------------------
API changes
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.10)

SET(RAMSES_VERSION_MAJOR 27)
SET(RAMSES_VERSION_MINOR 0)
SET(RAMSES_VERSION_PATCH 129)
SET(RAMSES_VERSION_PATCH 130)
SET(RAMSES_VERSION_POSTFIX "")

CMAKE_POLICY(SET CMP0048 NEW)
Expand Down
50 changes: 49 additions & 1 deletion client/ramses-client/impl/AppearanceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

// client API
#include "ramses-client-api/TextureSampler.h"
#include "ramses-client-api/TextureSamplerMS.h"
#include "ramses-client-api/TextureSamplerExternal.h"
#include "ramses-client-api/Effect.h"
#include "ramses-client-api/DataObject.h"

Expand Down Expand Up @@ -463,7 +465,7 @@ namespace ramses
const auto result = std::find(valueDataType.begin(), valueDataType.end(),input.getDataType());
if (result == valueDataType.end())
{
return addErrorEntry("Appearance::set failed, value type does not match input data type");
return addErrorEntry(::fmt::format("Appearance::set failed, value type does not match input data type {}", EnumToString(input.getDataType())));
}

if (input.getElementCount() != valueElementCount)
Expand Down Expand Up @@ -610,6 +612,52 @@ namespace ramses
return StatusOK;
}

status_t AppearanceImpl::getInputTextureMS(const EffectInputImpl& input, const TextureSamplerMS*& textureSampler)
{
textureSampler = nullptr;
CHECK_RETURN_ERR(checkEffectInputValidityAndValueCompatibility(input, 1u,
{ramses_internal::EDataType::TextureSampler2DMS}));

const ramses_internal::DataFieldHandle dataField(input.getInputIndex());
const auto samplerHandle = getIScene().getDataTextureSamplerHandle(m_uniformInstance, dataField);
if (samplerHandle.isValid())
{
RamsesObjectRegistryIterator iter(getSceneImpl().getObjectRegistry(), ERamsesObjectType_TextureSamplerMS);
while (const TextureSamplerMS* sampler = iter.getNext<TextureSamplerMS>())
{
if (samplerHandle == sampler->impl.getTextureSamplerHandle())
{
textureSampler = sampler;
break;
}
}
}
return StatusOK;
}

status_t AppearanceImpl::getInputTextureExternal(const EffectInputImpl& input, const TextureSamplerExternal*& textureSampler)
{
textureSampler = nullptr;
CHECK_RETURN_ERR(checkEffectInputValidityAndValueCompatibility(input, 1u,
{ramses_internal::EDataType::TextureSamplerExternal}));

const ramses_internal::DataFieldHandle dataField(input.getInputIndex());
const auto samplerHandle = getIScene().getDataTextureSamplerHandle(m_uniformInstance, dataField);
if (samplerHandle.isValid())
{
RamsesObjectRegistryIterator iter(getSceneImpl().getObjectRegistry(), ERamsesObjectType_TextureSamplerExternal);
while (const TextureSamplerExternal* sampler = iter.getNext<TextureSamplerExternal>())
{
if (samplerHandle == sampler->impl.getTextureSamplerHandle())
{
textureSampler = sampler;
break;
}
}
}
return StatusOK;
}

status_t AppearanceImpl::bindInput(const EffectInputImpl& input, const DataObjectImpl& dataObject)
{
if (!isFromTheSameSceneAs(dataObject))
Expand Down
2 changes: 2 additions & 0 deletions client/ramses-client/impl/AppearanceImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ namespace ramses

status_t setInputTexture(const EffectInputImpl& input, const TextureSamplerImpl& textureSampler);
status_t getInputTexture(const EffectInputImpl& input, const TextureSampler*& textureSampler);
status_t getInputTextureMS(const EffectInputImpl& input, const TextureSamplerMS*& textureSampler);
status_t getInputTextureExternal(const EffectInputImpl& input, const TextureSamplerExternal*& textureSampler);

status_t bindInput(const EffectInputImpl& input, const DataObjectImpl& dataObject);
status_t unbindInput(const EffectInputImpl& input);
Expand Down
1 change: 1 addition & 0 deletions client/ramses-client/impl/EffectInputUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace ramses
case ramses_internal::EDataType::Matrix44F : return EEffectInputDataType_Matrix44F;
case ramses_internal::EDataType::TextureSampler2D : return EEffectInputDataType_TextureSampler2D;
case ramses_internal::EDataType::TextureSampler2DMS : return EEffectInputDataType_TextureSampler2DMS;
case ramses_internal::EDataType::TextureSamplerExternal : return EEffectInputDataType_TextureSamplerExternal;
case ramses_internal::EDataType::TextureSampler3D : return EEffectInputDataType_TextureSampler3D;
case ramses_internal::EDataType::TextureSamplerCube : return EEffectInputDataType_TextureSamplerCube;
case ramses_internal::EDataType::Invalid : return EEffectInputDataType_Invalid;
Expand Down
2 changes: 2 additions & 0 deletions client/ramses-client/impl/RamsesObjectTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ namespace ramses
DEFINE_RAMSES_OBJECT_TRAITS(ArrayBuffer, ERamsesObjectType_DataBufferObject, ERamsesObjectType_SceneObject, true);
DEFINE_RAMSES_OBJECT_TRAITS(Texture2DBuffer, ERamsesObjectType_Texture2DBuffer, ERamsesObjectType_SceneObject, true);
DEFINE_RAMSES_OBJECT_TRAITS(SceneReference, ERamsesObjectType_SceneReference, ERamsesObjectType_SceneObject, true);
DEFINE_RAMSES_OBJECT_TRAITS(TextureSamplerExternal, ERamsesObjectType_TextureSamplerExternal, ERamsesObjectType_SceneObject, true);

struct RamsesObjectTraitsEntry
{
Expand Down Expand Up @@ -240,6 +241,7 @@ namespace ramses
DEFINE_RAMSES_OBJECT_TRAITS_LIST(ERamsesObjectType_DataVector4i)
DEFINE_RAMSES_OBJECT_TRAITS_LIST(ERamsesObjectType_StreamTexture)
DEFINE_RAMSES_OBJECT_TRAITS_LIST(ERamsesObjectType_SceneReference)
DEFINE_RAMSES_OBJECT_TRAITS_LIST(ERamsesObjectType_TextureSamplerExternal)
DATA_BIND_DEFINE_END()
}

Expand Down
3 changes: 2 additions & 1 deletion client/ramses-client/impl/RamsesObjectTypeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ namespace ramses
"ERamsesObjectType_DataVector3i",
"ERamsesObjectType_DataVector4i",
"ERamsesObjectType_StreamTexture",
"ERamsesObjectType_SceneReference"
"ERamsesObjectType_SceneReference",
"ERamsesObjectType_TextureSamplerExternal"
};

ENUM_TO_STRING(ERamsesObjectType, RamsesObjectTypeNames, ERamsesObjectType_NUMBER_OF_TYPES);
Expand Down
2 changes: 1 addition & 1 deletion client/ramses-client/impl/RenderBufferImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace ramses
{
usedAsTexture =
iscene.isTextureSamplerAllocated(sampler) &&
iscene.getTextureSampler(sampler).contentType == ramses_internal::TextureSampler::ContentType::RenderBuffer &&
iscene.getTextureSampler(sampler).isRenderBuffer() &&
iscene.getTextureSampler(sampler).contentHandle == getRenderBufferHandle().asMemoryHandle();
}

Expand Down
12 changes: 11 additions & 1 deletion client/ramses-client/impl/SceneDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "ramses-client-api/ArrayBuffer.h"
#include "ramses-client-api/Texture2DBuffer.h"
#include "ramses-client-api/GeometryBinding.h"
#include "ramses-client-api/TextureSamplerMS.h"
#include "ramses-client-api/TextureSamplerExternal.h"
#include "ramses-client-api/TextureSampler.h"
#include "ramses-client-api/StreamTexture.h"
#include "ramses-client-api/RenderTarget.h"
Expand Down Expand Up @@ -75,6 +77,12 @@ namespace ramses
void SceneDumper::setupMap(ramses_internal::HashMap<HandleType, const ObjectImplType*>& map)
{
map.clear();
addToMap<ObjectType, ObjectImplType, HandleType>(map);
}

template <class ObjectType, class ObjectImplType, class HandleType>
void SceneDumper::addToMap(ramses_internal::HashMap<HandleType, const ObjectImplType*>& map)
{
RamsesObjectRegistryIterator iterator(m_objectRegistry, TYPE_ID_OF_RAMSES_OBJECT<ObjectType>::ID);
while (const ObjectType* object = iterator.getNext<ObjectType>())
{
Expand Down Expand Up @@ -130,6 +138,8 @@ namespace ramses
void SceneDumper::setupMaps()
{
setupMap<TextureSampler, TextureSamplerImpl, ramses_internal::TextureSamplerHandle>(m_textureSamplerHandleToObjectMap);
addToMap<TextureSamplerMS, TextureSamplerImpl, ramses_internal::TextureSamplerHandle>(m_textureSamplerHandleToObjectMap);
addToMap<TextureSamplerExternal, TextureSamplerImpl, ramses_internal::TextureSamplerHandle>(m_textureSamplerHandleToObjectMap);
setupMap<RenderBuffer, RenderBufferImpl, ramses_internal::RenderBufferHandle>(m_renderBufferHandleToObjectMap);
setupMap<Texture2DBuffer, Texture2DBufferImpl, ramses_internal::TextureBufferHandle>(m_textureBufferHandleToObjectMap);
setupMap<StreamTexture, StreamTextureImpl, ramses_internal::StreamTextureHandle>(m_streamTextureHandleToObjectMap);
Expand Down Expand Up @@ -523,7 +533,7 @@ namespace ramses
for (auto textureSampler : requiredTextureSamplers)
{
const auto sampler = textureSampler->getIScene().getTextureSampler(textureSampler->getTextureSamplerHandle());
if (ramses_internal::TextureSampler::ContentType::RenderBuffer == sampler.contentType && ramses_internal::RenderBufferHandle::Invalid() != sampler.contentHandle)
if (sampler.isRenderBuffer() && ramses_internal::RenderBufferHandle::Invalid() != sampler.contentHandle)
{
const ramses_internal::RenderBufferHandle renderBufferHandle(sampler.contentHandle);
const RenderBufferImpl** renderBuffer = m_renderBufferHandleToObjectMap.get(renderBufferHandle);
Expand Down
3 changes: 3 additions & 0 deletions client/ramses-client/impl/SceneDumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ namespace ramses
template <class ObjectType, class ObjectImplType, class HandleType>
void setupMap(ramses_internal::HashMap<HandleType, const ObjectImplType*>& map);

template <class ObjectType, class ObjectImplType, class HandleType>
void addToMap(ramses_internal::HashMap<HandleType, const ObjectImplType*>& map);

void setupRenderBufferSetMap();
void setupRenderPassMap();
void setupResourceMap();
Expand Down
84 changes: 80 additions & 4 deletions client/ramses-client/impl/SceneImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ramses-client-api/RenderTarget.h"
#include "ramses-client-api/TextureSampler.h"
#include "ramses-client-api/TextureSamplerMS.h"
#include "ramses-client-api/TextureSamplerExternal.h"
#include "ramses-client-api/MeshNode.h"
#include "ramses-client-api/Texture2D.h"
#include "ramses-client-api/Texture3D.h"
Expand Down Expand Up @@ -115,6 +116,7 @@
#include "Utils/TextureMathUtils.h"
#include "ResourceDataPoolImpl.h"
#include "Components/FlushTimeInformation.h"
#include "fmt/format.h"

#include <array>

Expand Down Expand Up @@ -296,6 +298,9 @@ namespace ramses
case ERamsesObjectType_TextureSamplerMS:
status = createAndDeserializeObjectImpls<TextureSamplerMS, TextureSamplerImpl>(inStream, serializationContext, count);
break;
case ERamsesObjectType_TextureSamplerExternal:
status = createAndDeserializeObjectImpls<TextureSamplerExternal, TextureSamplerImpl>(inStream, serializationContext, count);
break;
case ERamsesObjectType_DataFloat:
status = createAndDeserializeObjectImpls<DataFloat, DataObjectImpl>(inStream, serializationContext, count);
break;
Expand Down Expand Up @@ -411,6 +416,22 @@ namespace ramses
}
}

// special validation (see SceneImpl::createTextureConsumer(const TextureSamplerExternal&, dataConsumerId_t)),
// duplicate IDs are temporarily allowed but validation still reports them as errors
// TODO vaclav do this properly
std::unordered_set<ramses_internal::DataSlotId> texConsumerIds;
for (const auto& it : m_scene.getDataSlots())
{
if (it.second->type == ramses_internal::EDataSlotType_TextureConsumer)
{
const auto consumerId = it.second->id;
if (texConsumerIds.count(consumerId) > 0u)
status = addValidationMessage(EValidationSeverity_Error,
fmt::format("Duplicate texture consumer ID '{}' is not allowed and will result in unknown behavior when linking on renderer", consumerId.getValue()).c_str());
texConsumerIds.insert(consumerId);
}
}

return status;
}

Expand Down Expand Up @@ -537,6 +558,9 @@ namespace ramses
case ERamsesObjectType_TextureSamplerMS:
destroyTextureSampler(RamsesObjectTypeUtils::ConvertTo<TextureSamplerMS>(object));
break;
case ERamsesObjectType_TextureSamplerExternal:
destroyTextureSampler(RamsesObjectTypeUtils::ConvertTo<TextureSamplerExternal>(object));
break;
case ERamsesObjectType_Appearance:
case ERamsesObjectType_GeometryBinding:
case ERamsesObjectType_RenderPass:
Expand Down Expand Up @@ -1062,6 +1086,47 @@ namespace ramses
return sampler;
}

ramses::TextureSamplerExternal* SceneImpl::createTextureSamplerExternal(ETextureSamplingMethod minSamplingMethod, ETextureSamplingMethod magSamplingMethod, const char *name)
{
if (ETextureSamplingMethod_Nearest != magSamplingMethod && ETextureSamplingMethod_Linear != magSamplingMethod)
{
LOG_ERROR(CONTEXT_CLIENT, "Scene::createTextureSamplerExternal failed, mag sampling method must be set to Nearest or Linear.");
return nullptr;
}

//Restrictions in spec section 3.7.14, https://registry.khronos.org/OpenGL/extensions/OES/OES_EGL_image_external.txt
//According to spec min filtering can only be linear or nearest
if (ETextureSamplingMethod_Nearest != minSamplingMethod && ETextureSamplingMethod_Linear != minSamplingMethod)
{
LOG_ERROR(CONTEXT_CLIENT, "Scene::createTextureSamplerExternal failed, min sampling method must be set to Nearest or Linear for external textures.");
return nullptr;
}

//According to spec clamp to edge so the only allowed wrap mode
constexpr ETextureAddressMode wrapUMode = ETextureAddressMode_Clamp;
constexpr ETextureAddressMode wrapVMode = ETextureAddressMode_Clamp;

ramses_internal::TextureSamplerStates samplerStates(
TextureUtils::GetTextureAddressModeInternal(wrapUMode),
TextureUtils::GetTextureAddressModeInternal(wrapVMode),
ramses_internal::EWrapMethod::Clamp,
TextureUtils::GetTextureSamplingInternal(minSamplingMethod),
TextureUtils::GetTextureSamplingInternal(magSamplingMethod)
);

TextureSamplerImpl& samplerImpl = *new TextureSamplerImpl(*this, ERamsesObjectType_TextureSamplerExternal, name);
samplerImpl.initializeFrameworkData(
samplerStates,
ERamsesObjectType_TextureSamplerExternal,
ramses_internal::TextureSampler::ContentType::ExternalTexture,
ramses_internal::ResourceContentHash::Invalid(),
ramses_internal::InvalidMemoryHandle);

TextureSamplerExternal* sampler = new TextureSamplerExternal(samplerImpl);
registerCreatedObject(*sampler);
return sampler;
}

ramses::TextureSampler* SceneImpl::createTextureSamplerImpl(
ETextureAddressMode wrapUMode,
ETextureAddressMode wrapVMode,
Expand Down Expand Up @@ -1374,18 +1439,29 @@ namespace ramses
return createTextureConsumerImpl(sampler, id);
}

status_t SceneImpl::createTextureConsumer(const TextureSamplerExternal& sampler, dataConsumerId_t id)
{
// Allow duplicate consumer ID for external samplers (special need for ramses composer).
// This will NOT work properly if consumers with same ID get to renderer side and attempt to be linked
// (or if one is already linked and another one with same ID is created).
// TODO vaclav make this proper, allow it in general and handle duplicates on renderer side

return createTextureConsumerImpl(sampler, id, false);
}

template <typename SAMPLER>
status_t SceneImpl::createTextureConsumerImpl(const SAMPLER& sampler, dataConsumerId_t id)
status_t SceneImpl::createTextureConsumerImpl(const SAMPLER& sampler, dataConsumerId_t id, bool checkDuplicate)
{
if (!containsSceneObject(sampler.impl))
{
return addErrorEntry("Scene::createTextureConsumer failed, texture sampler is not from this scene.");
}

const ramses_internal::DataSlotId internalDataSlotId(id.getValue());
if (ramses_internal::DataSlotUtils::HasDataSlotId(m_scene, internalDataSlotId))
if (checkDuplicate)
{
return addErrorEntry("Scene::createTextureConsumer failed, duplicate data slot id");
if (ramses_internal::DataSlotUtils::HasDataSlotId(m_scene, internalDataSlotId))
return addErrorEntry("Scene::createTextureConsumer failed, duplicate data slot id");
}

const ramses_internal::TextureSamplerHandle& samplerHandle = sampler.impl.getTextureSamplerHandle();
Expand Down Expand Up @@ -1435,7 +1511,7 @@ namespace ramses
{
const auto now = ramses_internal::FlushTime::Clock::now();
const auto nowMs = std::chrono::time_point_cast<std::chrono::milliseconds>(now);
LOG_INFO_P(CONTEXT_CLIENT, "Scene::resetUniformTimeMs: {}", nowMs.time_since_epoch().count());
LOG_INFO_P(CONTEXT_CLIENT, "Scene({})::resetUniformTimeMs: {}", getSceneId(), nowMs.time_since_epoch().count());
m_sendEffectTimeSync = true;
getIScene().setEffectTimeSync(now);
return StatusOK;
Expand Down
Loading

0 comments on commit 5963bf6

Please sign in to comment.