-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ren] added beginning of impl of quad renderer
- Loading branch information
Showing
7 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef TOPAZ_REN_QUAD_HPP | ||
#define TOPAZ_REN_QUAD_HPP | ||
#include "tz/core/handle.hpp" | ||
#include "tz/gpu/graph.hpp" | ||
|
||
namespace tz::ren | ||
{ | ||
namespace detail | ||
{ | ||
struct quad_t{}; | ||
struct quadren_t{}; | ||
} | ||
using quad_handle = tz::handle<detail::quad_t>; | ||
using quad_renderer_handle = tz::handle<detail::quadren_t>; | ||
|
||
struct quad_renderer_info | ||
{ | ||
|
||
}; | ||
|
||
std::expected<quad_renderer_handle, tz::error_code> create_quad_renderer(quad_renderer_info info); | ||
tz::error_code destroy_quad_renderer(quad_renderer_handle renh); | ||
|
||
struct quad_info | ||
{ | ||
|
||
}; | ||
std::expected<quad_handle, tz::error_code> quad_renderer_create_quad(quad_renderer_handle renh, quad_info info); | ||
|
||
tz::gpu::graph_handle quad_renderer_graph(quad_renderer_handle renh); | ||
} | ||
|
||
#endif // TOPAZ_REN_QUAD_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "tz/ren/quad.hpp" | ||
#include "tz/topaz.hpp" | ||
#include "tz/gpu/resource.hpp" | ||
#include "tz/gpu/pass.hpp" | ||
#include "tz/gpu/graph.hpp" | ||
#include "tz/gpu/shader.hpp" | ||
|
||
#include ImportedShaderHeader(quad, vertex) | ||
#include ImportedShaderHeader(quad, fragment) | ||
|
||
namespace tz::ren | ||
{ | ||
struct quad_renderer_data | ||
{ | ||
quad_renderer_info info = {}; | ||
tz::gpu::resource_handle data_buffer = tz::nullhand; | ||
tz::gpu::pass_handle main_pass = tz::nullhand; | ||
tz::gpu::graph_handle graph = tz::nullhand; | ||
}; | ||
|
||
std::vector<quad_renderer_data> renderers; | ||
|
||
std::expected<quad_renderer_handle, tz::error_code> create_quad_renderer(quad_renderer_info info) | ||
{ | ||
std::size_t id = renderers.size(); | ||
auto& ren = renderers.emplace_back(); | ||
ren.info = info; | ||
|
||
return static_cast<tz::hanval>(id); | ||
} | ||
|
||
tz::error_code destroy_quad_renderer(quad_renderer_handle renh) | ||
{ | ||
auto& ren = renderers[renh.peek()]; | ||
tz::gpu::destroy_pass(ren.main_pass); | ||
auto ret = tz::gpu::destroy_resource(ren.data_buffer); | ||
ren = {}; | ||
return ret; | ||
} | ||
|
||
std::expected<quad_handle, tz::error_code> quad_renderer_create_quad(quad_renderer_handle renh, quad_info info) | ||
{ | ||
(void)renh; | ||
(void)info; | ||
UNERR(tz::error_code::engine_bug, "create quad is NYI"); | ||
} | ||
|
||
tz::gpu::graph_handle quad_renderer_graph(quad_renderer_handle renh) | ||
{ | ||
return renderers[renh.peek()].graph; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
shader(type = fragment); | ||
|
||
void main() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
shader(type = vertex); | ||
|
||
void main() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "tz/topaz.hpp" | ||
#include "tz/ren/quad.hpp" | ||
#include "tz/os/window.hpp" | ||
#include "tz/gpu/hardware.hpp" | ||
|
||
int main() | ||
{ | ||
tz::initialise(); | ||
tz::os::open_window({}); | ||
|
||
tz::gpu::hardware gpu = tz::gpu::find_best_hardware(); | ||
tz_must(tz::gpu::use_hardware(gpu)); | ||
|
||
tz::ren::quad_renderer_handle ren = tz_must(tz::ren::create_quad_renderer({})); | ||
|
||
//tz_must(tz::ren::destroy_quad_renderer(ren)); | ||
while(tz::os::window_is_open()) | ||
{ | ||
tz::os::window_update(); | ||
tz::gpu::execute(tz::ren::quad_renderer_graph(ren)); | ||
} | ||
|
||
tz::terminate(); | ||
} |