Instead of passing SamplerInterfaceBlocks and a SamplerBindingMap to Program, we now set a 'sampler group' per binding point: Program::addSamplerGroup(...) A sampler group here consists of a list of N 'Sampler' and a 'Sampler' is just a unique name (unifrom name in the shader) and binding point in the shader. That's all the driver layer needs. With this change we get rid of the code that re-created the uniform names in the driver -- this should never have been done there. And we also remove the hash-map lookups in vulkan and metal drivers.
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
/*
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <utils/CString.h>
|
|
|
|
#include <utils/compiler.h>
|
|
|
|
#include <memory>
|
|
|
|
namespace utils {
|
|
|
|
int StaticString::compare(const StaticString& rhs) const noexcept {
|
|
size_type lhs_size = size();
|
|
size_type rhs_size = rhs.size();
|
|
if (lhs_size < rhs_size) return -1;
|
|
if (lhs_size > rhs_size) return 1;
|
|
return strncmp(data(), rhs.data(), size());
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
UTILS_NOINLINE
|
|
CString::CString(const char* cstr, size_t length) {
|
|
if (length && cstr) {
|
|
assert(length == strlen(cstr));
|
|
Data* p = (Data*)malloc(sizeof(Data) + length + 1);
|
|
p->length = (size_type)length;
|
|
mCStr = (value_type*)(p + 1);
|
|
// we don't use memcpy here to avoid a call to libc, the generated code is pretty good.
|
|
std::uninitialized_copy_n(cstr, length + 1, mCStr);
|
|
}
|
|
}
|
|
|
|
CString::CString(const char* cstr)
|
|
: CString(cstr, size_type(cstr ? strlen(cstr) : 0)) {
|
|
}
|
|
|
|
CString::CString(const CString& rhs)
|
|
: CString(rhs.c_str(), rhs.size()) {
|
|
}
|
|
|
|
CString& CString::operator=(const CString& rhs) {
|
|
if (this != &rhs) {
|
|
auto const p = mData ? mData - 1 : nullptr;
|
|
new(this) CString(rhs);
|
|
free(p);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
} // namespace utils
|