Merge git://github.com/stuartcarnie/SPIRV-Cross

This commit is contained in:
Hans-Kristian Arntzen 2019-05-18 10:37:38 +02:00
commit e04bbd0948
2 changed files with 49 additions and 0 deletions

View File

@ -1281,6 +1281,11 @@ const char *spvc_compiler_get_member_decoration_string(spvc_compiler compiler, s
.c_str();
}
const char *spvc_compiler_get_member_name(spvc_compiler compiler, spvc_type_id id, unsigned member_index)
{
return compiler->compiler->get_member_name(id, member_index).c_str();
}
spvc_result spvc_compiler_get_entry_points(spvc_compiler compiler, const spvc_entry_point **entry_points,
size_t *num_entry_points)
{
@ -1648,6 +1653,32 @@ spvc_constant_id spvc_compiler_get_work_group_size_specialization_constants(spvc
return ret;
}
spvc_result spvc_compiler_get_active_buffer_ranges(spvc_compiler compiler,
spvc_variable_id id,
const spvc_buffer_range **ranges,
size_t *num_ranges)
{
SPVC_BEGIN_SAFE_SCOPE
{
auto active_ranges = compiler->compiler->get_active_buffer_ranges(id);
SmallVector<spvc_buffer_range> translated;
translated.reserve(active_ranges.size());
for (auto &r : active_ranges)
{
spvc_buffer_range trans = { r.index, r.offset, r.range };
translated.push_back(trans);
}
auto ptr = spvc_allocate<TemporaryBuffer<spvc_buffer_range>>();
ptr->buffer = std::move(translated);
*ranges = ptr->buffer.data();
*num_ranges = ptr->buffer.size();
compiler->context->allocations.push_back(std::move(ptr));
}
SPVC_END_SAFE_SCOPE(compiler->context, SPVC_ERROR_OUT_OF_MEMORY)
return SPVC_SUCCESS;
}
float spvc_constant_get_scalar_fp16(spvc_constant constant, unsigned column, unsigned row)
{
return constant->scalar_f16(column, row);

View File

@ -111,6 +111,14 @@ typedef struct spvc_specialization_constant
unsigned constant_id;
} spvc_specialization_constant;
/* See C++ API. */
typedef struct spvc_buffer_range
{
unsigned index;
size_t offset;
size_t range;
} spvc_buffer_range;
/* See C++ API. */
typedef struct spvc_hlsl_root_constants
{
@ -578,6 +586,7 @@ SPVC_PUBLIC_API unsigned spvc_compiler_get_member_decoration(spvc_compiler compi
unsigned member_index, SpvDecoration decoration);
SPVC_PUBLIC_API const char *spvc_compiler_get_member_decoration_string(spvc_compiler compiler, spvc_type_id id,
unsigned member_index, SpvDecoration decoration);
SPVC_PUBLIC_API const char *spvc_compiler_get_member_name(spvc_compiler compiler, spvc_type_id id, unsigned member_index);
/*
* Entry points.
@ -670,6 +679,15 @@ SPVC_PUBLIC_API spvc_constant_id spvc_compiler_get_work_group_size_specializatio
spvc_specialization_constant *y,
spvc_specialization_constant *z);
/*
* Buffer ranges
* Maps to C++ API.
*/
SPVC_PUBLIC_API spvc_result spvc_compiler_get_active_buffer_ranges(spvc_compiler compiler,
spvc_variable_id id,
const spvc_buffer_range **ranges,
size_t *num_ranges);
/*
* No stdint.h until C99, sigh :(
* For smaller types, the result is sign or zero-extended as appropriate.