Improve ResourceLimits interface to be more forward compatible

New interface allows users to generate ResourceLimits for interface so
that additions to TBuiltInResource do not break the ABI.

Users should use the glslang-default-resource-limits library and the
Public/ResourceLimits.h header. Similar changes have been made to the
C interface. Use Public/resource_limits_c.h.

Fixes #2822
This commit is contained in:
Greg Fischer
2022-10-28 17:27:18 -06:00
parent 980ac50813
commit 90c5214344
11 changed files with 47 additions and 30 deletions

View File

@@ -26,15 +26,20 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#include "resource_limits_c.h"
#include "ResourceLimits.h"
#include "glslang/Public/resource_limits_c.h"
#include "glslang/Public/ResourceLimits.h"
#include <stdlib.h>
#include <string.h>
#include <string>
glslang_resource_t* glslang_resource(void)
{
return reinterpret_cast<glslang_resource_t*>(GetResources());
}
const glslang_resource_t* glslang_default_resource(void)
{
return reinterpret_cast<const glslang_resource_t*>(&glslang::DefaultTBuiltInResource);
return reinterpret_cast<const glslang_resource_t*>(GetDefaultResources());
}
#if defined(__clang__) || defined(__GNUC__)
@@ -47,7 +52,7 @@ const glslang_resource_t* glslang_default_resource(void)
const char* glslang_default_resource_string()
{
std::string cpp_str = glslang::GetDefaultTBuiltInResourceString();
std::string cpp_str = GetDefaultTBuiltInResourceString();
char* c_str = (char*)malloc(cpp_str.length() + 1);
strcpy(c_str, cpp_str.c_str());
return c_str;
@@ -61,5 +66,5 @@ const char* glslang_default_resource_string()
void glslang_decode_resource_limits(glslang_resource_t* resources, char* config)
{
glslang::DecodeResourceLimits(reinterpret_cast<TBuiltInResource*>(resources), config);
DecodeResourceLimits(reinterpret_cast<TBuiltInResource*>(resources), config);
}