Program::shader() now only takes a void* + size
Program::shader() was taking a string before which didn't make sense for spirv. Now it's just a blob, in the case of GL/Metal, the blob must be a null terminated c-string, and the size must include the terminating null character. This fixes an out-of-bound access in ShaderBuilder::getShader() (which doesn't exist anymore), because it was creating a CString passing a size that included the null terminating char, which is not was CString expects. CString can now assert() in that case. driver::Program now uses a std::vector<> for storage, which we should fix at some point (b/c it's a public header). CString was not suited to store binary blobs.
This commit is contained in:
committed by
Mathias Agopian
parent
955ab2d2f3
commit
f2ba48f4a7
@@ -35,9 +35,7 @@ int StaticString::compare(const StaticString& rhs) const noexcept {
|
||||
UTILS_NOINLINE
|
||||
CString::CString(const char* cstr, size_type length) {
|
||||
if (length && cstr) {
|
||||
// I think we can't use this assert with vulkan, because shaders are returned as CString
|
||||
// (see ShaderBuilder).
|
||||
// assert(length == strlen(cstr));
|
||||
assert(length == strlen(cstr));
|
||||
Data* p = (Data*)malloc(sizeof(Data) + length + 1);
|
||||
p->length = length;
|
||||
mCStr = (value_type*)(p + 1);
|
||||
|
||||
Reference in New Issue
Block a user