Skip to content

Commit 5cd7555

Browse files
committed
more
1 parent d92ea84 commit 5cd7555

7 files changed

Lines changed: 156 additions & 170 deletions

File tree

src/block.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct
77
bool is_sprite;
88
bool is_solid;
99
bool is_occluded;
10-
bool has_shadow;
10+
bool is_shadowed;
1111
int indices[6];
1212
light_t light;
1313
}
@@ -19,7 +19,7 @@ static const BLOCKS[BLOCK_COUNT] =
1919
.is_sprite = false,
2020
.is_solid = true,
2121
.is_occluded = true,
22-
.has_shadow = true,
22+
.is_shadowed = true,
2323
.indices = {2, 2, 2, 2, 1, 3},
2424
.light = {0, 0, 0, 0},
2525
},
@@ -29,7 +29,7 @@ static const BLOCKS[BLOCK_COUNT] =
2929
.is_sprite = false,
3030
.is_solid = true,
3131
.is_occluded = true,
32-
.has_shadow = true,
32+
.is_shadowed = true,
3333
.indices = {3, 3, 3, 3, 3, 3},
3434
.light = {0, 0, 0, 0},
3535
},
@@ -39,7 +39,7 @@ static const BLOCKS[BLOCK_COUNT] =
3939
.is_sprite = false,
4040
.is_solid = true,
4141
.is_occluded = true,
42-
.has_shadow = true,
42+
.is_shadowed = true,
4343
.indices = {5, 5, 5, 5, 5, 5},
4444
.light = {0, 0, 0, 0},
4545
},
@@ -49,7 +49,7 @@ static const BLOCKS[BLOCK_COUNT] =
4949
.is_sprite = false,
5050
.is_solid = true,
5151
.is_occluded = true,
52-
.has_shadow = true,
52+
.is_shadowed = true,
5353
.indices = {6, 6, 6, 6, 6, 6},
5454
.light = {0, 0, 0, 0},
5555
},
@@ -59,7 +59,7 @@ static const BLOCKS[BLOCK_COUNT] =
5959
.is_sprite = false,
6060
.is_solid = true,
6161
.is_occluded = true,
62-
.has_shadow = true,
62+
.is_shadowed = true,
6363
.indices = {4, 4, 4, 4, 4, 4},
6464
.light = {0, 0, 0, 0},
6565
},
@@ -69,7 +69,7 @@ static const BLOCKS[BLOCK_COUNT] =
6969
.is_sprite = false,
7070
.is_solid = true,
7171
.is_occluded = true,
72-
.has_shadow = true,
72+
.is_shadowed = true,
7373
.indices = {8, 8, 8, 8, 7, 7},
7474
.light = {0, 0, 0, 0},
7575
},
@@ -79,7 +79,7 @@ static const BLOCKS[BLOCK_COUNT] =
7979
.is_sprite = false,
8080
.is_solid = true,
8181
.is_occluded = true,
82-
.has_shadow = true,
82+
.is_shadowed = true,
8383
.indices = {10, 10, 10, 10, 10, 10},
8484
.light = {0, 0, 0, 0},
8585
},
@@ -89,7 +89,7 @@ static const BLOCKS[BLOCK_COUNT] =
8989
.is_sprite = false,
9090
.is_solid = true,
9191
.is_occluded = false,
92-
.has_shadow = true,
92+
.is_shadowed = true,
9393
.indices = {9, 9, 9, 9, 9, 9},
9494
.light = {0, 0, 0, 0},
9595
},
@@ -99,7 +99,7 @@ static const BLOCKS[BLOCK_COUNT] =
9999
.is_sprite = true,
100100
.is_solid = false,
101101
.is_occluded = false,
102-
.has_shadow = false,
102+
.is_shadowed = false,
103103
.indices = {15, 15, 15, 15, 15, 15},
104104
.light = {0, 0, 0, 0},
105105
},
@@ -109,7 +109,7 @@ static const BLOCKS[BLOCK_COUNT] =
109109
.is_sprite = true,
110110
.is_solid = false,
111111
.is_occluded = false,
112-
.has_shadow = false,
112+
.is_shadowed = false,
113113
.indices = {13, 13, 13, 13, 13, 13},
114114
.light = {0, 0, 0, 0},
115115
},
@@ -119,7 +119,7 @@ static const BLOCKS[BLOCK_COUNT] =
119119
.is_sprite = true,
120120
.is_solid = false,
121121
.is_occluded = false,
122-
.has_shadow = false,
122+
.is_shadowed = false,
123123
.indices = {12, 12, 12, 12, 12, 12},
124124
.light = {0, 0, 0, 0},
125125
},
@@ -129,7 +129,7 @@ static const BLOCKS[BLOCK_COUNT] =
129129
.is_sprite = true,
130130
.is_solid = false,
131131
.is_occluded = false,
132-
.has_shadow = false,
132+
.is_shadowed = false,
133133
.indices = {11, 11, 11, 11, 11, 11},
134134
.light = {0, 0, 0, 0},
135135
},
@@ -139,7 +139,7 @@ static const BLOCKS[BLOCK_COUNT] =
139139
.is_sprite = true,
140140
.is_solid = false,
141141
.is_occluded = false,
142-
.has_shadow = false,
142+
.is_shadowed = false,
143143
.indices = {14, 14, 14, 14, 14, 14},
144144
.light = {0, 0, 0, 0},
145145
},
@@ -149,7 +149,7 @@ static const BLOCKS[BLOCK_COUNT] =
149149
.is_sprite = false,
150150
.is_solid = false,
151151
.is_occluded = false,
152-
.has_shadow = false,
152+
.is_shadowed = false,
153153
.indices = {16, 16, 16, 16, 16, 16},
154154
.light = {0, 0, 0, 0},
155155
},
@@ -159,8 +159,8 @@ static const BLOCKS[BLOCK_COUNT] =
159159
.is_sprite = true,
160160
.is_solid = false,
161161
.is_occluded = false,
162+
.is_shadowed = false,
162163
.indices = {17, 17, 17, 17, 17, 17},
163-
.has_shadow = false,
164164
.light = {255, 255, 0, 10},
165165
},
166166
};
@@ -185,9 +185,9 @@ bool block_is_occluded(block_t block)
185185
return BLOCKS[block].is_occluded;
186186
}
187187

188-
bool block_has_shadow(block_t block)
188+
bool block_is_shadowed(block_t block)
189189
{
190-
return BLOCKS[block].has_shadow;
190+
return BLOCKS[block].is_shadowed;
191191
}
192192

193193
int block_get_index(block_t block, direction_t direction)

src/block.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool block_is_opaque(block_t block);
4444
bool block_is_sprite(block_t block);
4545
bool block_is_solid(block_t block);
4646
bool block_is_occluded(block_t block);
47-
bool block_has_shadow(block_t block);
47+
bool block_is_shadowed(block_t block);
4848
int block_get_index(block_t block, direction_t direction);
4949
bool block_is_light(block_t block);
5050
light_t block_get_light(block_t block);

src/buffer.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,6 @@
66
static _Thread_local SDL_GPUCommandBuffer* command_buffer;
77
static _Thread_local SDL_GPUCopyPass* copy_pass;
88

9-
bool gpu_begin_upload(SDL_GPUDevice* device)
10-
{
11-
CHECK(!command_buffer);
12-
CHECK(!copy_pass);
13-
command_buffer = SDL_AcquireGPUCommandBuffer(device);
14-
if (!command_buffer)
15-
{
16-
SDL_Log("Failed to acquire command buffer: %s", SDL_GetError());
17-
return false;
18-
}
19-
copy_pass = SDL_BeginGPUCopyPass(command_buffer);
20-
if (!copy_pass)
21-
{
22-
SDL_Log("Failed to begin copy pass: %s", SDL_GetError());
23-
SDL_CancelGPUCommandBuffer(command_buffer);
24-
return false;
25-
}
26-
return true;
27-
}
28-
29-
void gpu_end_upload(SDL_GPUDevice* device)
30-
{
31-
CHECK(copy_pass);
32-
CHECK(command_buffer);
33-
SDL_EndGPUCopyPass(copy_pass);
34-
SDL_SubmitGPUCommandBuffer(command_buffer);
35-
copy_pass = NULL;
36-
command_buffer = NULL;
37-
}
38-
399
void cpu_buffer_init(cpu_buffer_t* cpu, SDL_GPUDevice* device, Uint32 stride)
4010
{
4111
CHECK(stride);
@@ -174,3 +144,33 @@ void gpu_buffer_clear(gpu_buffer_t* gpu)
174144
{
175145
gpu->size = 0;
176146
}
147+
148+
bool gpu_buffer_begin_upload(SDL_GPUDevice* device)
149+
{
150+
CHECK(!command_buffer);
151+
CHECK(!copy_pass);
152+
command_buffer = SDL_AcquireGPUCommandBuffer(device);
153+
if (!command_buffer)
154+
{
155+
SDL_Log("Failed to acquire command buffer: %s", SDL_GetError());
156+
return false;
157+
}
158+
copy_pass = SDL_BeginGPUCopyPass(command_buffer);
159+
if (!copy_pass)
160+
{
161+
SDL_Log("Failed to begin copy pass: %s", SDL_GetError());
162+
SDL_CancelGPUCommandBuffer(command_buffer);
163+
return false;
164+
}
165+
return true;
166+
}
167+
168+
void gpu_buffer_end_upload(SDL_GPUDevice* device)
169+
{
170+
CHECK(copy_pass);
171+
CHECK(command_buffer);
172+
SDL_EndGPUCopyPass(copy_pass);
173+
SDL_SubmitGPUCommandBuffer(command_buffer);
174+
copy_pass = NULL;
175+
command_buffer = NULL;
176+
}

src/buffer.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
#include <SDL3/SDL.h>
44

5-
bool gpu_begin_upload(SDL_GPUDevice* device);
6-
void gpu_end_upload(SDL_GPUDevice* device);
7-
85
typedef struct cpu_buffer
96
{
107
SDL_GPUDevice* device;
@@ -35,4 +32,5 @@ void gpu_buffer_init(gpu_buffer_t* gpu, SDL_GPUDevice* device, SDL_GPUBufferUsag
3532
void gpu_buffer_free(gpu_buffer_t* gpu);
3633
void gpu_buffer_upload(gpu_buffer_t* gpu, cpu_buffer_t* cpu);
3734
void gpu_buffer_clear(gpu_buffer_t* gpu);
38-
35+
bool gpu_buffer_begin_upload(SDL_GPUDevice* device);
36+
void gpu_buffer_end_upload(SDL_GPUDevice* device);

0 commit comments

Comments
 (0)