Skip to content

Commit

Permalink
RoundedQuad, NineSlice.
Browse files Browse the repository at this point in the history
- Fix sector UVs and verts.
  • Loading branch information
karnkaul committed Aug 23, 2023
1 parent c411568 commit c7a2686
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 83 deletions.
29 changes: 21 additions & 8 deletions engine/include/le/graphics/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,40 @@ struct Quad {
};

struct Circle {
static constexpr std::uint8_t resolution_v{128};
static constexpr int resolution_v{128};

float diameter{1.0f};
std::uint32_t resolution{resolution_v};
int resolution{resolution_v};
Rgba rgb{white_v};
glm::vec3 origin{};

auto operator==(Circle const&) const -> bool = default;
};

struct RoundedQuad : Quad {
float corner_radius{0.25f};
int corner_resolution{8};

auto operator==(RoundedQuad const&) const -> bool = default;
};

struct NineSlice {
glm::vec2 size{1.0f};
glm::vec2 top{0.25f};
glm::vec2 bottom{0.25f};
struct Size {
glm::vec2 total{1.0f};
glm::vec2 top{0.25f};
glm::vec2 bottom{0.25f};

[[nodiscard]] auto rescaled(glm::vec2 extent) const -> Size;

auto operator==(Size const&) const -> bool = default;
};

Size size{};
UvRect top_uv{.lt = {}, .rb = glm::vec2{0.25f}};
UvRect bottom_uv{.lt = glm::vec2{0.75f}, .rb = glm::vec2{1.0f}};
bool rounded_corners{}; // TODO
Rgba rgb{white_v};
glm::vec3 origin{};

[[nodiscard]] auto rescaled(glm::vec2 extent) const -> NineSlice;

auto operator==(NineSlice const&) const -> bool = default;
};

Expand Down Expand Up @@ -83,6 +95,7 @@ struct Geometry {

auto append(Quad const& quad) -> Geometry&;
auto append(Circle const& circle) -> Geometry&;
auto append(RoundedQuad const& rounded_quad) -> Geometry&;
auto append(NineSlice const& nine_slice) -> Geometry&;

auto append(Cube const& cube) -> Geometry&;
Expand Down
2 changes: 1 addition & 1 deletion engine/include/le/graphics/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Renderer : public MonoInstance<Renderer> {
auto bake_objects(RenderFrame const& render_frame) -> void;

std::unique_ptr<DearImGui> m_imgui{};
PipelineCache m_pipeline_cache;
PipelineCache m_pipeline_cache{};
SamplerCache m_sampler_cache{};
DescriptorCache m_descriptor_cache{};
ScratchBufferCache m_scratch_buffer_cache{};
Expand Down
2 changes: 1 addition & 1 deletion engine/src/graphics/cache/pipeline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ auto PipelineCache::clear_pipelines() -> void {
}

auto PipelineCache::clear_pipelines_and_shaders() -> void {
Device::self().get_device().waitIdle();
m_device.waitIdle();
clear_pipelines();
m_shader_cache.clear_shaders();
}
Expand Down
4 changes: 2 additions & 2 deletions engine/src/graphics/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ auto make_device(Gpu const& gpu) -> vk::UniqueDevice {
}
}

auto dynamic_rendering_feature = vk::PhysicalDeviceDynamicRenderingFeatures{1};
auto synchronization_2_feature = vk::PhysicalDeviceSynchronization2FeaturesKHR{1};
auto dynamic_rendering_feature = vk::PhysicalDeviceDynamicRenderingFeatures{vk::True};
auto synchronization_2_feature = vk::PhysicalDeviceSynchronization2FeaturesKHR{vk::True};
synchronization_2_feature.pNext = &dynamic_rendering_feature;

dci.queueCreateInfoCount = 1;
Expand Down

0 comments on commit c7a2686

Please sign in to comment.