int
glsl_type::coordinate_components() const
{
- int size;
-
- switch (sampler_dimensionality) {
- case GLSL_SAMPLER_DIM_1D:
- case GLSL_SAMPLER_DIM_BUF:
- size = 1;
- break;
- case GLSL_SAMPLER_DIM_2D:
- case GLSL_SAMPLER_DIM_RECT:
- case GLSL_SAMPLER_DIM_MS:
- case GLSL_SAMPLER_DIM_EXTERNAL:
- case GLSL_SAMPLER_DIM_SUBPASS:
- size = 2;
- break;
- case GLSL_SAMPLER_DIM_3D:
- case GLSL_SAMPLER_DIM_CUBE:
- size = 3;
- break;
- default:
- assert(!"Should not get here.");
- size = 1;
- break;
- }
+ enum glsl_sampler_dim dim = (enum glsl_sampler_dim)sampler_dimensionality;
+ int size = glsl_get_sampler_dim_coordinate_components(dim);
/* Array textures need an additional component for the array index, except
* for cubemap array images that behave like a 2D array of interleaved
}
return 1;
}
+
+extern "C" {
+
+int
+glsl_get_sampler_dim_coordinate_components(enum glsl_sampler_dim dim)
+{
+ switch (dim) {
+ case GLSL_SAMPLER_DIM_1D:
+ case GLSL_SAMPLER_DIM_BUF:
+ return 1;
+ case GLSL_SAMPLER_DIM_2D:
+ case GLSL_SAMPLER_DIM_RECT:
+ case GLSL_SAMPLER_DIM_MS:
+ case GLSL_SAMPLER_DIM_EXTERNAL:
+ case GLSL_SAMPLER_DIM_SUBPASS:
+ return 2;
+ case GLSL_SAMPLER_DIM_3D:
+ case GLSL_SAMPLER_DIM_CUBE:
+ return 3;
+ default:
+ unreachable("Unknown sampler dim");
+ }
+}
+
+}
const struct glsl_type *decode_type_from_blob(struct blob_reader *blob);
-#ifdef __cplusplus
-}
-#endif
-
typedef void (*glsl_type_size_align_func)(const struct glsl_type *type,
unsigned *size, unsigned *align);
GLSL_SAMPLER_DIM_SUBPASS_MS, /* for multisampled vulkan input attachments */
};
+int
+glsl_get_sampler_dim_coordinate_components(enum glsl_sampler_dim dim);
+
enum glsl_matrix_layout {
/**
* The layout of the matrix is inherited from the object containing the
};
#ifdef __cplusplus
+} /* extern "C" */
+
#include "GL/gl.h"
#include "util/ralloc.h"
#include "main/menums.h" /* for gl_texture_index, C++'s enum rules are broken */