Skip to content
This repository was archived by the owner on May 9, 2026. It is now read-only.

Commit 31d1add

Browse files
committed
Fix spirv code output truncation when --sgs set [release 1.15.0]
1 parent 7485c43 commit 31d1add

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

README.md

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

1212
### 1.15.0
1313

14+
- Fix spirv code output truncation when --sgs set
1415
- Add --profile version support for SPIRV (default: 100)
1516
- Update spirv-cross: 542db37(4130) (Until Nov 7, 2025)
1617
- Update glslang: 1c7030f(5357) (Until Nov 11, 2025)

src/axslcc.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
// 1.13.0 Target MSL default version to 2.0
6767
// 1.13.1 Split legacy --automap option into two distinct flags: --auto-map-bindings (for resource bindings) and --auto-map-locations (for shader I/O locations).
6868
// 1.13.2 Add option --inline-ubo-members, previous option name: --flatten-ubos is deprecated
69+
// 1.15.0 Fix spirv code output truncation when --sgs set
70+
// Add --profile version support for SPIRV (default: 100)
71+
// Update spirv-cross: 542db37(4130) (Until Nov 7, 2025)
72+
// Update glslang: 1c7030f(5357) (Until Nov 11, 2025)
73+
// Remove SPVRemapper linkage
74+
//
6975

7076
/**
7177
* @since 1.9.5
@@ -103,7 +109,9 @@
103109

104110
#include "axslc-writer.h"
105111

112+
#ifdef _WIN32
106113
#include <d3dcompiler.h>
114+
#endif
107115

108116
// sjson
109117
#define sjson_malloc(user, size) sx_malloc((const sx_alloc*)user, size)
@@ -116,8 +124,8 @@
116124
#include "../3rdparty/sjson/sjson.h"
117125

118126
#define VERSION_MAJOR 1
119-
#define VERSION_MINOR 13
120-
#define VERSION_SUB 2
127+
#define VERSION_MINOR 15
128+
#define VERSION_SUB 0
121129

122130
using namespace axslc;
123131

@@ -461,6 +469,7 @@ static void parse_defines(cmd_args* args, const char* defines)
461469
static sx_mem_block* d3d_compile_binary(const char* code, const char* filename,
462470
int profile_version, EShLanguage stage, int debug)
463471
{
472+
#ifdef _WIN32
464473
ID3DBlob* output = NULL;
465474
ID3DBlob* errors = NULL;
466475

@@ -511,6 +520,9 @@ static sx_mem_block* d3d_compile_binary(const char* code, const char* filename,
511520
output->GetBufferPointer());
512521
output->Release();
513522
return mem;
523+
#else
524+
return nullptr;
525+
#endif
514526
}
515527

516528
static void cleanup_args(cmd_args* args)
@@ -1401,7 +1413,7 @@ static int cross_compile(const cmd_args& args, std::vector<uint32_t>& spirv,
14011413
sx_mem_block* mem = d3d_compile_binary(code.c_str(), args.out_filepath, args.profile_ver,
14021414
stage, args.debug_bin);
14031415
if (!mem) {
1404-
printf("Bytecode compilation of '%s' failed\n", args.out_filepath);
1416+
printf("HLSL bytecode compilation of '%s' failed\n", args.out_filepath);
14051417
return -1;
14061418
}
14071419

@@ -1411,7 +1423,7 @@ static int cross_compile(const cmd_args& args, std::vector<uint32_t>& spirv,
14111423
if (args.lang != SHADER_LANG_SPIRV) {
14121424
sc_add_stage_code(g_sgs, sstage, code.c_str());
14131425
} else {
1414-
sc_add_stage_code_bin(g_sgs, sstage, spirv.data(), (int)spirv.size());
1426+
sc_add_stage_code_bin(g_sgs, sstage, spirv.data(), static_cast<int>(spirv.size() * sizeof(uint32_t)));
14151427
}
14161428
}
14171429

@@ -1445,7 +1457,7 @@ static int cross_compile(const cmd_args& args, std::vector<uint32_t>& spirv,
14451457
sx_mem_block* mem = d3d_compile_binary(code.c_str(), filepath.c_str(), args.profile_ver,
14461458
stage, args.debug_bin);
14471459
if (!mem) {
1448-
printf("Bytecode compilation of '%s' failed\n", filepath.c_str());
1460+
printf("HLSL bytecode compilation of '%s' failed\n", filepath.c_str());
14491461
return -1;
14501462
}
14511463

0 commit comments

Comments
 (0)