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

Feature/serializer #9

Closed
wants to merge 2 commits into from

Conversation

Tehsapper
Copy link
Collaborator

implemented material serializer & deserializer


class Uniform {
protected:
std::string name;
UniformType type;
UniformValueType value_type;
bool changed;

virtual ByteWriter& serialize(ByteWriter& writer) const {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make better serialization interface
move it to cpp file

Copy link
Owner

@hotstreams hotstreams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix fast&furious

@@ -30,16 +49,25 @@ namespace GraphicsEngine {

[[nodiscard]] virtual Uniform* clone() noexcept = 0;
virtual void set(const ShaderProgram& shader) = 0;

friend ByteWriter& operator<<(ByteWriter& writer, const Uniform& u) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate definition from declaration

UniformValue(const std::string& name, UniformType type, const T& value);

ByteWriter& serializeFields(ByteWriter& writer) const;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using more template/constexpr/compile-time language features

public:
explicit UniformSampler(ByteReader& reader);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not want

@@ -5,21 +5,40 @@
#include <chrono>
#include <core/texture_visitor.hpp>
#include <core/context_debug.hpp>
#include <util/bytewriter.hpp>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not want

@@ -59,6 +64,12 @@ namespace GraphicsEngine {

[[nodiscard]] virtual Material* clone() const noexcept;

static constexpr uint32_t serial_version = 0x1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h3h

try {
sampler = assets.textures.at(path);
}
catch (const resource_container_error& err) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not ... or resource_container_error ?

@@ -221,3 +263,30 @@ namespace GraphicsEngine {
template class UniformValue<glm::mat3>;
template class UniformValue<glm::mat4>;
}

std::unique_ptr<Uniform> GraphicsEngine::deserializeUniformValue(ByteReader& reader) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want copy elission

for (size_t i = 0; i < size; ++i) {
PropertyType ptype {reader};
auto uptr = deserializeUniform(reader);
material_builder.add(ptype, std::move(uptr));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a che ne material_builder.add(ptype,deserializeUniform(reader));

nah lishniy move

}
}

return material_builder.build();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a che esly material - custom ??????????////////

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom material eto drugaya cool story

@@ -192,3 +192,8 @@ MaterialType MaterialBuilder::getMaterialType() const noexcept {

return MaterialType{std::move(props), material->shading};
}

MaterialBuilder& MaterialBuilder::add(PropertyType type, std::unique_ptr<Uniform> uniform) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rip


enum class UniformType { Value, Sampler, Time };
enum class UniformValueType { Float, Int, Uint, Vec2, Vec3, Vec4, Mat3, Mat4 };
enum class UniformValueType { Invalid, Float, Int, Uint, Vec2, Vec3, Vec4, Mat3, Mat4 };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want valid state

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soryan need poison value

public:
explicit Uniform(ByteReader& reader) : changed{false} {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont want

public:
explicit UniformValue(ByteReader& reader);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tresh

@@ -68,7 +100,15 @@ namespace GraphicsEngine {
class UniformTime : public UniformValue<float> {
private:
std::chrono::time_point<std::chrono::steady_clock> start;
protected:
ByteWriter& serialize(ByteWriter& writer) const override {
writer << UniformType::Time;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmmm

@hotstreams hotstreams closed this Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants