Add get_member_name and active_buffer_ranges to C APIs

This commit is contained in:
Stuart Carnie 2019-05-08 10:20:36 -07:00
Родитель 255c6981be
Коммит 72a8c9f35a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 848D9C9718D78B4F
2 изменённых файлов: 49 добавлений и 0 удалений

Просмотреть файл

@ -1276,6 +1276,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)
{
@ -1643,6 +1648,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);

Просмотреть файл

@ -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
{
@ -567,6 +575,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.
@ -659,6 +668,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.