Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit 4320a86

Browse files
committed
Write sc size into binary header [release 3.3.0]
1 parent 3dbb7e8 commit 4320a86

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ if (NOT (IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/3rdparty/glslang"))
7171
message(STATUS "Downloading glslang ...")
7272
find_program(GIT_COMMAND NAMES git REQUIRED)
7373
execute_process(COMMAND ${GIT_COMMAND} clone "https://github.com/KhronosGroup/glslang.git" "${CMAKE_CURRENT_LIST_DIR}/3rdparty/glslang")
74+
execute_process(COMMAND ${GIT_COMMAND} -C "${CMAKE_CURRENT_LIST_DIR}/3rdparty/glslang" checkout "dffbc79733f63435ae24e73f64384f1374e0dda2")
7475
find_program(PYTHON_COMMAND NAMES python3 python REQUIRED)
7576
execute_process(COMMAND ${PYTHON_COMMAND} "${CMAKE_CURRENT_LIST_DIR}/3rdparty/glslang/update_glslang_sources.py"
7677
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/3rdparty/glslang")

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ It uses [glslang](https://github.com/KhronosGroup/glslang) for parsing GLSL and
99

1010
## ChangeLog
1111

12+
### 3.3.0
13+
14+
- Write sc size into binary header
15+
- Update glslang: dffbc79(5382) (Until Dec 12, 2025)
16+
1217
### 3.2.0
1318

1419
- Unify and re-enumerate vertex input & uniform variable types (Break changes)

src/axslc-writer.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,18 @@ bool sc_commit(sc_file* f)
148148

149149
// write main chunk
150150
const uint32_t sc_magic = SC_CHUNK;
151-
const uint32_t sc_size = 0; // doesn't matter
152-
sx_file_write_var(&writer, sc_magic);
153-
sx_file_write_var(&writer, sc_size);
151+
uint32_t sc_size = 0; // place holder
152+
153+
sc_size += sx_file_write_var(&writer, sc_magic);
154+
const uint32_t sc_size_offset = sizeof(sc_magic);
155+
sc_size += sx_file_write_var(&writer, sc_size);
154156

155157
sc_chunk sc_header;
156158
sc_header.major = f->major_ver;
157159
sc_header.minor = f->minor_ver;
158160
sc_header.lang = f->lang;
159161
sc_header.profile_ver = f->profile_ver;
160-
sx_file_write_var(&writer, sc_header);
162+
sc_size += sx_file_write_var(&writer, sc_header);
161163

162164
// write stages
163165
for (int i = 0; i < sx_array_count(f->stages); i++) {
@@ -174,34 +176,38 @@ bool sc_commit(sc_file* f)
174176

175177
// `STAG`
176178
const uint32_t _stage = SC_CHUNK_STAG;
177-
sx_file_write_var(&writer, _stage);
178-
sx_file_write_var(&writer, stage_size);
179-
sx_file_write_var(&writer, s->stage);
179+
sc_size += sx_file_write_var(&writer, _stage);
180+
sc_size += sx_file_write_var(&writer, stage_size);
181+
sc_size += sx_file_write_var(&writer, s->stage);
180182

181183
if (code_size) {
182184
// `CODE`
183185
const uint32_t _code = SC_CHUNK_CODE;
184186
const uint32_t code_size = sx_strlen(s->code) + 1;
185-
sx_file_write_var(&writer, _code);
186-
sx_file_write_var(&writer, code_size);
187-
sx_file_write(&writer, s->code, code_size);
187+
sc_size += sx_file_write_var(&writer, _code);
188+
sc_size += sx_file_write_var(&writer, code_size);
189+
sc_size += sx_file_write(&writer, s->code, code_size);
188190
} else if (data_size) {
189191
// `DATA`
190192
const uint32_t _data = SC_CHUNK_DATA;
191-
sx_file_write_var(&writer, _data);
192-
sx_file_write_var(&writer, s->data_size);
193-
sx_file_write(&writer, s->data, s->data_size);
193+
sc_size += sx_file_write_var(&writer, _data);
194+
sc_size += sx_file_write_var(&writer, s->data_size);
195+
sc_size += sx_file_write(&writer, s->data, s->data_size);
194196
}
195197

196198
// `REFL`
197199
if (s->refl) {
198200
const uint32_t _refl = SC_CHUNK_REFL;
199-
sx_file_write_var(&writer, _refl);
200-
sx_file_write_var(&writer, s->refl_size);
201-
sx_file_write(&writer, s->refl, s->refl_size);
201+
sc_size += sx_file_write_var(&writer, _refl);
202+
sc_size += sx_file_write_var(&writer, s->refl_size);
203+
sc_size += sx_file_write(&writer, s->refl, s->refl_size);
202204
}
203205
}
204206

207+
// finish sc size
208+
sx_file_seekw(&writer, sc_size_offset, SX_WHENCE_BEGIN);
209+
sx_file_write_var(&writer, sc_size);
210+
205211
sx_file_close_writer(&writer);
206212

207213
return true;

src/axslcc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
// 3.1.1 Register builtin sampler state symbols
7777
//
7878
// 3.2.0 Unify and re-enumerate vertex input & uniform variable types
79+
// 3.3.0 Write sc size into binary header
7980
//
8081

8182
/**
@@ -133,7 +134,7 @@
133134
#include "../3rdparty/sjson/sjson.h"
134135

135136
#define AXSLCC_VERSION_MAJOR 3
136-
#define AXSLCC_VERSION_MINOR 2
137+
#define AXSLCC_VERSION_MINOR 3
137138
#define AXSLCC_VERSION_REVISION 0
138139

139140
using namespace axslc;

0 commit comments

Comments
 (0)