Skip to content

Commit 4b52ef9

Browse files
authored
Merge pull request #211 from floooh/error-on-unsupported-texture-type
Error on unsupported texture type
2 parents e169652 + 923a7d5 commit 4b52ef9

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
### **23-Feb-2026**
5+
6+
sokol-shdc not throws an error when encountering unsupported texture uniform
7+
types (see https://github.com/floooh/sokol-tools/issues/209).
8+
9+
PR: https://github.com/floooh/sokol-tools/pull/210
10+
411
### **07-Feb-2026**
512

613
When generating binary output, the metal command line compiler is now called

src/shdc/reflection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Reflection Reflection::build(const Args& args, const Input& inp, const std::arra
149149
return res;
150150
}
151151

152-
static ImageType::Enum spirtype_to_image_type(const SPIRType& type) {
152+
ImageType::Enum Reflection::spirtype_to_image_type(const SPIRType& type) {
153153
if (type.image.arrayed) {
154154
if (type.image.dim == spv::Dim2D) {
155155
return ImageType::ARRAY;

src/shdc/reflection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ struct Reflection {
2727
// print a debug dump to stderr
2828
void dump_debug(ErrMsg::Format err_fmt) const;
2929

30+
// helper: convert SPIRType to ImageType
31+
static ImageType::Enum spirtype_to_image_type(const spirv_cross::SPIRType& type);
32+
3033
private:
3134
// create a set of unique resource bindings from shader snippet input bindings
3235
static Bindings merge_bindings(const std::vector<Bindings>& in_bindings, bool to_prog_bindings, ErrMsg& out_error);

src/shdc/spirvcross.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static ErrMsg validate_resource_restrictions(const Input& inp, const SpirvBlob&
211211
// - must not be readonly
212212
// - must have specific pixel formats
213213
// - must use separate image and sampler objects
214+
// - 1D-textures / textureBuffers not supported
214215
//
215216
// FIXME: disallow vec3 arrays
216217
//
@@ -282,6 +283,12 @@ static ErrMsg validate_resource_restrictions(const Input& inp, const SpirvBlob&
282283
return ErrMsg::error(inp.base_path, 0, fmt::format("storage image '{}': access format must be one of rgba8_snorm, rgba8i, rgba8ui, rgba16ui, rgba16i, rgba16f, r32ui, r32i, r32f, rg32ui, rg32i, rg32f, rgba32ui, rgba32i, rgba32f", simg_res.name));
283284
}
284285
}
286+
for (const Resource& tex_res: res.separate_images) {
287+
const SPIRType& tex_type = compiler.get_type(tex_res.type_id);
288+
if (Reflection::spirtype_to_image_type(tex_type) == ImageType::INVALID) {
289+
return ErrMsg::error(inp.base_path, 0, fmt::format("texture '{}': unsupported texture type (must be texture2D[MS], texture3D, textureCube or texture2DArray)", tex_res.name));
290+
}
291+
}
285292
if (res.sampled_images.size() > 0) {
286293
return ErrMsg::error(inp.base_path, 0, fmt::format("combined image sampler '{}' detected, please use separate textures and samplers", res.sampled_images[0].name));
287294
}

0 commit comments

Comments
 (0)