summaryrefslogtreecommitdiff
path: root/video.hpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-12-23 21:30:13 +1100
committerquou <quou@disroot.org>2024-12-23 21:30:13 +1100
commit078b97e48b5ad5fcf3f5a16bb081ea0efb1f931b (patch)
treed04bfb2d25952b214a4df303823ff7c5d2743681 /video.hpp
parentb293168cc158d65f1a5146f155921ff82119d1bc (diff)
send textures to shaders
Diffstat (limited to 'video.hpp')
-rw-r--r--video.hpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/video.hpp b/video.hpp
index f05af57..dc0574e 100644
--- a/video.hpp
+++ b/video.hpp
@@ -39,10 +39,35 @@ struct Vertex_Format_Id : public Primitive_Id<uint32_t> {
struct Shader_Id : public Primitive_Id<uint32_t> {
using Primitive_Id<uint32_t>::Primitive_Id;
};
+struct Sampler_Id : public Primitive_Id<uint32_t> {
+ using Primitive_Id<uint32_t>::Primitive_Id;
+};
+
+struct Descriptor {
+ enum class Type {
+ texture
+ } type;
+ int slot;
+ Descriptor* next;
+};
+
+struct Texture_Descriptor : public Descriptor {
+ Sampler_Id sampler;
+ Texture_Id texture;
+};
struct Pipeline {
Vertex_Format_Id vertex_format;
Shader_Id shader;
+ Descriptor* descriptors;
+
+ int count_descriptors() const {
+ const Descriptor* d = descriptors;
+ int c = 0;
+ for (; d; d = d->next)
+ c++;
+ return c;
+ }
};
struct Colour {
@@ -92,6 +117,7 @@ struct Pipeline_Builder {
void begin();
void shader(Shader_Id s);
void vertex_format(Vertex_Format_Id vf);
+ void texture(int binding, Texture_Id t, Sampler_Id s);
Pipeline& build();
void validate();
};
@@ -126,6 +152,30 @@ struct Buffer {
Buffer_Id id;
};
+enum class Filter_Mode {
+ point,
+ linear
+};
+
+enum class Address_Mode {
+ repeat,
+ mirror,
+ clamp,
+ border
+};
+
+struct Sampler_State {
+ Filter_Mode min;
+ Filter_Mode mag;
+ Filter_Mode mip;
+ Address_Mode address_u;
+ Address_Mode address_v;
+ Address_Mode address_w;
+ float border[4];
+ float mip_bias;
+ bool aniso;
+};
+
struct Context;
struct Shader;
struct Device {
@@ -156,6 +206,9 @@ struct Device {
void destroy_buffer(Buffer_Id id);
Shader& get_shader(Shader_Id id);
+
+ Sampler_Id create_sampler(const Sampler_State& state);
+ void destroy_sampler(Sampler_Id id);
};
struct Context {
@@ -186,6 +239,8 @@ struct Shader : public Asset {
int binding_index(const char* name);
int attribute_index(const char* name);
int target_index(const char* name);
+ int descriptor_index(const char* name);
+ int descriptor_stage(int slot);
};
#endif