Skip to content

Commit

Permalink
Export root constants Kope code and handle the render target format
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 19, 2024
1 parent ed739ac commit af971f8
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Sources/backends/hlsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ void hlsl_export(char *directory, api_kind d3d) {
global_register_indices[i] = srv_index;
srv_index += 1;
}
else if (g->type == float_id) {
else if (get_type(g->type)->built_in) {
}
else {
global_register_indices[i] = cbv_index;
Expand Down
88 changes: 88 additions & 0 deletions Sources/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,94 @@ void globals_init(void) {
add_global_with_value(float_id, attributes, add_name("BLENDOP_MIN"), int_value);
int_value.value.ints[0] = 4;
add_global_with_value(float_id, attributes, add_name("BLENDOP_MAX"), int_value);

global_value uint_value;
uint_value.kind = GLOBAL_VALUE_UINT;

uint_value.value.uints[0] = 0;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R8_UNORM"), uint_value);
uint_value.value.uints[0] = 1;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R8_SNORM"), uint_value);
uint_value.value.uints[0] = 2;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R8_UINT"), uint_value);
uint_value.value.uints[0] = 3;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R8_SINT"), uint_value);
uint_value.value.uints[0] = 4;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R16_UINT"), uint_value);
uint_value.value.uints[0] = 5;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R16_SINT"), uint_value);
uint_value.value.uints[0] = 6;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R16_FLOAT"), uint_value);
uint_value.value.uints[0] = 7;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG8_UNORM"), uint_value);
uint_value.value.uints[0] = 8;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG8_SNORM"), uint_value);
uint_value.value.uints[0] = 9;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG8_UINT"), uint_value);
uint_value.value.uints[0] = 10;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG8_SINT"), uint_value);
uint_value.value.uints[0] = 11;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R32_UINT"), uint_value);
uint_value.value.uints[0] = 12;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R32_SINT"), uint_value);
uint_value.value.uints[0] = 13;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_R32_FLOAT"), uint_value);
uint_value.value.uints[0] = 14;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG16_UINT"), uint_value);
uint_value.value.uints[0] = 15;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG16_SINT"), uint_value);
uint_value.value.uints[0] = 16;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG16_FLOAT"), uint_value);
uint_value.value.uints[0] = 17;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA8_UNORM"), uint_value);
uint_value.value.uints[0] = 18;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA8_UNORM_SRGB"), uint_value);
uint_value.value.uints[0] = 19;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA8_SNORM"), uint_value);
uint_value.value.uints[0] = 20;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA8_UINT"), uint_value);
uint_value.value.uints[0] = 21;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA8_SINT"), uint_value);
uint_value.value.uints[0] = 22;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_BGRA8_UNORM"), uint_value);
uint_value.value.uints[0] = 23;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_BGRA8_UNORM_SRGB"), uint_value);
uint_value.value.uints[0] = 24;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGB9E5U_FLOAT"), uint_value);
uint_value.value.uints[0] = 25;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGB10A2_UINT"), uint_value);
uint_value.value.uints[0] = 26;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGB10A2_UNORM"), uint_value);
uint_value.value.uints[0] = 27;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG11B10U_FLOAT"), uint_value);
uint_value.value.uints[0] = 28;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG32_UINT"), uint_value);
uint_value.value.uints[0] = 29;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG32_SINT"), uint_value);
uint_value.value.uints[0] = 30;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RG32_FLOAT"), uint_value);
uint_value.value.uints[0] = 31;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA16_UINT"), uint_value);
uint_value.value.uints[0] = 32;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA16_SINT"), uint_value);
uint_value.value.uints[0] = 33;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA16_FLOAT"), uint_value);
uint_value.value.uints[0] = 34;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA32_UINT"), uint_value);
uint_value.value.uints[0] = 35;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA32_SINT"), uint_value);
uint_value.value.uints[0] = 36;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_RGBA32_FLOAT"), uint_value);
uint_value.value.uints[0] = 37;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_DEPTH16_UNORM"), uint_value);
uint_value.value.uints[0] = 38;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_DEPTH24PLUS_NOTHING8"), uint_value);
uint_value.value.uints[0] = 39;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_DEPTH24PLUS_STENCIL8"), uint_value);
uint_value.value.uints[0] = 40;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_DEPTH32FLOAT"), uint_value);
uint_value.value.uints[0] = 41;
add_global_with_value(uint_id, attributes, add_name("TEXTURE_FORMAT_DEPTH32FLOAT_STENCIL8_NOTHING24"), uint_value);
}

global_id add_global(type_id type, attribute_list attributes, name_id name) {
Expand Down
5 changes: 5 additions & 0 deletions Sources/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ typedef struct global_value {
GLOBAL_VALUE_INT2,
GLOBAL_VALUE_INT3,
GLOBAL_VALUE_INT4,
GLOBAL_VALUE_UINT,
GLOBAL_VALUE_UINT2,
GLOBAL_VALUE_UINT3,
GLOBAL_VALUE_UINT4,
GLOBAL_VALUE_BOOL,
GLOBAL_VALUE_NONE
} kind;
union {
float floats[4];
int ints[4];
unsigned uints[4];
bool b;
} value;
} global_value;
Expand Down
Loading

0 comments on commit af971f8

Please sign in to comment.