Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more towards using only static strings for debug tags #8478

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions filament/include/filament/BufferObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <backend/BufferDescriptor.h>

#include <utils/compiler.h>
#include <utils/StaticString.h>

#include <stdint.h>
#include <stddef.h>
Expand Down Expand Up @@ -90,9 +91,21 @@ class UTILS_PUBLIC BufferObject : public FilamentAPI {
* @param name A string to identify this BufferObject
* @param len Length of name, should be less than or equal to 128
* @return This Builder, for chaining calls.
* @deprecated Use name(utils::StaticString const&) instead.
*/
UTILS_DEPRECATED
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;

/**
* Associate an optional name with this BufferObject for debugging purposes.
*
* name will show in error messages and should be kept as short as possible.
*
* @param name A string literal to identify this BufferObject
* @return This Builder, for chaining calls.
*/
Builder& name(utils::StaticString const& name) noexcept;

/**
* Creates the BufferObject and returns a pointer to it. After creation, the buffer
* object is uninitialized. Use BufferObject::setBuffer() to initialize it.
Expand Down
7 changes: 7 additions & 0 deletions filament/include/filament/FilamentAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <utils/compiler.h>
#include <utils/PrivateImplementation.h>
#include <utils/CString.h>
#include <utils/StaticString.h>

#include <stddef.h>

Expand Down Expand Up @@ -61,11 +62,17 @@ UTILS_PUBLIC void builderMakeName(utils::CString& outName, const char* name, siz
template <typename Builder>
class UTILS_PUBLIC BuilderNameMixin {
public:
UTILS_DEPRECATED
Builder& name(const char* name, size_t len) noexcept {
builderMakeName(mName, name, len);
return static_cast<Builder&>(*this);
}

Builder& name(utils::StaticString const& name) noexcept {
builderMakeName(mName, name.data(), name.size());
return static_cast<Builder&>(*this);
}

utils::CString const& getName() const noexcept { return mName; }

private:
Expand Down
13 changes: 13 additions & 0 deletions filament/include/filament/IndexBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <backend/BufferDescriptor.h>

#include <utils/compiler.h>
#include <utils/StaticString.h>

#include <stdint.h>
#include <stddef.h>
Expand Down Expand Up @@ -95,9 +96,21 @@ class UTILS_PUBLIC IndexBuffer : public FilamentAPI {
* @param name A string to identify this IndexBuffer
* @param len Length of name, should be less than or equal to 128
* @return This Builder, for chaining calls.
* @deprecated Use name(utils::StaticString const&) instead.
*/
UTILS_DEPRECATED
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;

/**
* Associate an optional name with this IndexBuffer for debugging purposes.
*
* name will show in error messages and should be kept as short as possible.
*
* @param name A string literal to identify this IndexBuffer
* @return This Builder, for chaining calls.
*/
Builder& name(utils::StaticString const& name) noexcept;

/**
* Creates the IndexBuffer object and returns a pointer to it. After creation, the index
* buffer is uninitialized. Use IndexBuffer::setBuffer() to initialize the IndexBuffer.
Expand Down
13 changes: 13 additions & 0 deletions filament/include/filament/InstanceBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <filament/Engine.h>

#include <utils/compiler.h>
#include <utils/StaticString.h>

#include <math/mathfwd.h>

Expand Down Expand Up @@ -82,9 +83,21 @@ class UTILS_PUBLIC InstanceBuffer : public FilamentAPI {
* @param name A string to identify this InstanceBuffer
* @param len Length of name, should be less than or equal to 128
* @return This Builder, for chaining calls.
* @deprecated Use name(utils::StaticString const&) instead.
*/
UTILS_DEPRECATED
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;

/**
* Associate an optional name with this InstanceBuffer for debugging purposes.
*
* name will show in error messages and should be kept as short as possible.
*
* @param name A string literal to identify this InstanceBuffer
* @return This Builder, for chaining calls.
*/
Builder& name(utils::StaticString const& name) noexcept;

/**
* Creates the InstanceBuffer object and returns a pointer to it.
*/
Expand Down
13 changes: 13 additions & 0 deletions filament/include/filament/MorphTargetBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <filament/Engine.h>

#include <utils/compiler.h>
#include <utils/StaticString.h>

#include <math/mathfwd.h>

Expand Down Expand Up @@ -75,9 +76,21 @@ class UTILS_PUBLIC MorphTargetBuffer : public FilamentAPI {
* @param name A string to identify this MorphTargetBuffer
* @param len Length of name, should be less than or equal to 128
* @return This Builder, for chaining calls.
* @deprecated Use name(utils::StaticString const&) instead.
*/
UTILS_DEPRECATED
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;

/**
* Associate an optional name with this MorphTargetBuffer for debugging purposes.
*
* name will show in error messages and should be kept as short as possible.
*
* @param name A string literal to identify this MorphTargetBuffer
* @return This Builder, for chaining calls.
*/
Builder& name(utils::StaticString const& name) noexcept;

/**
* Creates the MorphTargetBuffer object and returns a pointer to it.
*
Expand Down
13 changes: 13 additions & 0 deletions filament/include/filament/SkinningBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <filament/RenderableManager.h>

#include <utils/compiler.h>
#include <utils/StaticString.h>

#include <math/mathfwd.h>

Expand Down Expand Up @@ -81,9 +82,21 @@ class UTILS_PUBLIC SkinningBuffer : public FilamentAPI {
* @param name A string to identify this SkinningBuffer
* @param len Length of name, should be less than or equal to 128
* @return This Builder, for chaining calls.
* @deprecated Use name(utils::StaticString const&) instead.
*/
UTILS_DEPRECATED
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;

/**
* Associate an optional name with this SkinningBuffer for debugging purposes.
*
* name will show in error messages and should be kept as short as possible.
*
* @param name A string literal to identify this SkinningBuffer
* @return This Builder, for chaining calls.
*/
Builder& name(utils::StaticString const& name) noexcept;

/**
* Creates the SkinningBuffer object and returns a pointer to it.
*
Expand Down
13 changes: 13 additions & 0 deletions filament/include/filament/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <backend/CallbackHandler.h>

#include <utils/compiler.h>
#include <utils/StaticString.h>

#include <stdint.h>

Expand Down Expand Up @@ -148,9 +149,21 @@ class UTILS_PUBLIC Stream : public FilamentAPI {
* @param name A string to identify this Stream
* @param len Length of name, should be less than or equal to 128
* @return This Builder, for chaining calls.
* @deprecated Use name(utils::StaticString const&) instead.
*/
UTILS_DEPRECATED
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;

/**
* Associate an optional name with this Stream for debugging purposes.
*
* name will show in error messages and should be kept as short as possible.
*
* @param name A string literal to identify this Stream
* @return This Builder, for chaining calls.
*/
Builder& name(utils::StaticString const& name) noexcept;

/**
* Creates the Stream object and returns a pointer to it.
*
Expand Down
15 changes: 14 additions & 1 deletion filament/include/filament/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <backend/Platform.h>

#include <utils/compiler.h>
#include <utils/StaticString.h>

#include <utility>

Expand Down Expand Up @@ -222,8 +223,20 @@ class UTILS_PUBLIC Texture : public FilamentAPI {
* @param name A string to identify this Texture
* @param len Length of name, should be less than or equal to 128
* @return This Builder, for chaining calls.
* @deprecated Use name(utils::StaticString const&) instead.
*/
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
UTILS_DEPRECATED
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;

/**
* Associate an optional name with this Texture for debugging purposes.
*
* name will show in error messages and should be kept as short as possible.
*
* @param name A string literal to identify this Texture
* @return This Builder, for chaining calls.
*/
Builder& name(utils::StaticString const& name) noexcept;

/**
* Creates an external texture. The content must be set using setExternalImage().
Expand Down
13 changes: 13 additions & 0 deletions filament/include/filament/VertexBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <backend/DriverEnums.h>

#include <utils/compiler.h>
#include <utils/StaticString.h>

#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -170,9 +171,21 @@ class UTILS_PUBLIC VertexBuffer : public FilamentAPI {
* @param name A string to identify this VertexBuffer
* @param len Length of name, should be less than or equal to 128
* @return This Builder, for chaining calls.
* @deprecated Use name(utils::StaticString const&) instead.
*/
UTILS_DEPRECATED
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;

/**
* Associate an optional name with this VertexBuffer for debugging purposes.
*
* name will show in error messages and should be kept as short as possible.
*
* @param name A string literal to identify this VertexBuffer
* @return This Builder, for chaining calls.
*/
Builder& name(utils::StaticString const& name) noexcept;

/**
* Creates the VertexBuffer object and returns a pointer to it.
*
Expand Down
5 changes: 5 additions & 0 deletions filament/src/details/BufferObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "FilamentAPI-impl.h"

#include <utils/CString.h>
#include <utils/StaticString.h>

namespace filament {

Expand Down Expand Up @@ -51,6 +52,10 @@ BufferObject::Builder& BufferObject::Builder::name(const char* name, size_t cons
return BuilderNameMixin::name(name, len);
}

BufferObject::Builder& BufferObject::Builder::name(utils::StaticString const& name) noexcept {
return BuilderNameMixin::name(name);
}

BufferObject* BufferObject::Builder::build(Engine& engine) {
return downcast(engine).createBufferObject(*this);
}
Expand Down
5 changes: 5 additions & 0 deletions filament/src/details/IndexBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "FilamentAPI-impl.h"

#include <utils/CString.h>
#include <utils/StaticString.h>

namespace filament {

Expand Down Expand Up @@ -51,6 +52,10 @@ IndexBuffer::Builder& IndexBuffer::Builder::name(const char* name, size_t const
return BuilderNameMixin::name(name, len);
}

IndexBuffer::Builder& IndexBuffer::Builder::name(utils::StaticString const& name) noexcept {
return BuilderNameMixin::name(name);
}

IndexBuffer* IndexBuffer::Builder::build(Engine& engine) {
return downcast(engine).createIndexBuffer(*this);
}
Expand Down
6 changes: 6 additions & 0 deletions filament/src/details/InstanceBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "FilamentAPI-impl.h"

#include <utils/StaticString.h>

#include <math/mat3.h>
#include <math/vec3.h>

Expand Down Expand Up @@ -54,6 +56,10 @@ InstanceBuffer::Builder& InstanceBuffer::Builder::name(const char* name, size_t
return BuilderNameMixin::name(name, len);
}

InstanceBuffer::Builder& InstanceBuffer::Builder::name(utils::StaticString const& name) noexcept {
return BuilderNameMixin::name(name);
}

InstanceBuffer* InstanceBuffer::Builder::build(Engine& engine) {
FILAMENT_CHECK_PRECONDITION(mImpl->mInstanceCount >= 1) << "instanceCount must be >= 1.";
FILAMENT_CHECK_PRECONDITION(mImpl->mInstanceCount <= engine.getMaxAutomaticInstances())
Expand Down
5 changes: 5 additions & 0 deletions filament/src/details/MorphTargetBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <math/norm.h>

#include <utils/CString.h>
#include <utils/StaticString.h>

namespace filament {

Expand Down Expand Up @@ -59,6 +60,10 @@ MorphTargetBuffer::Builder& MorphTargetBuffer::Builder::name(const char* name, s
return BuilderNameMixin::name(name, len);
}

MorphTargetBuffer::Builder& MorphTargetBuffer::Builder::name(utils::StaticString const& name) noexcept {
return BuilderNameMixin::name(name);
}

MorphTargetBuffer* MorphTargetBuffer::Builder::build(Engine& engine) {
return downcast(engine).createMorphTargetBuffer(*this);
}
Expand Down
5 changes: 5 additions & 0 deletions filament/src/details/SkinningBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <math/mat4.h>

#include <utils/CString.h>
#include <utils/StaticString.h>

#include <string.h>
#include <stddef.h>
Expand Down Expand Up @@ -64,6 +65,10 @@ SkinningBuffer::Builder& SkinningBuffer::Builder::name(const char* name, size_t
return BuilderNameMixin::name(name, len);
}

SkinningBuffer::Builder& SkinningBuffer::Builder::name(utils::StaticString const& name) noexcept {
return BuilderNameMixin::name(name);
}

SkinningBuffer* SkinningBuffer::Builder::build(Engine& engine) {
return downcast(engine).createSkinningBuffer(*this);
}
Expand Down
5 changes: 5 additions & 0 deletions filament/src/details/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <backend/PixelBufferDescriptor.h>

#include <utils/CString.h>
#include <utils/StaticString.h>
#include <utils/Panic.h>
#include <filament/Stream.h>

Expand Down Expand Up @@ -65,6 +66,10 @@ Stream::Builder& Stream::Builder::name(const char* name, size_t const len) noexc
return BuilderNameMixin::name(name, len);
}

Stream::Builder& Stream::Builder::name(utils::StaticString const& name) noexcept {
return BuilderNameMixin::name(name);
}

Stream* Stream::Builder::build(Engine& engine) {
return downcast(engine).createStream(*this);
}
Expand Down
Loading