Compare commits
1 Commits
rc/1.69.4
...
zm/test-pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07356a2949 |
@@ -222,6 +222,56 @@ public:
|
||||
return static_cast<Dp>(p);
|
||||
}
|
||||
|
||||
template<typename Dp, typename B>
|
||||
inline std::enable_if_t<
|
||||
std::is_pointer_v<Dp> && std::is_base_of_v<B, std::remove_pointer_t<Dp>>, int16_t>
|
||||
handle_set_value(Handle<B>& handle, uint8_t v) {
|
||||
assert_invariant(handle);
|
||||
auto [p, tag] = handleToPointer(handle.getId());
|
||||
|
||||
if (isPoolHandle(handle.getId())) {
|
||||
// check for pool handle use-after-free
|
||||
if (UTILS_UNLIKELY(!mUseAfterFreeCheckDisabled)) {
|
||||
auto const pNode = static_cast<typename Allocator::Node*>(p);
|
||||
pNode[-1].test_value = v;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
// check for heap handle use-after-free
|
||||
if (UTILS_UNLIKELY(!mUseAfterFreeCheckDisabled)) {
|
||||
return -1;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Dp, typename B>
|
||||
inline std::enable_if_t<
|
||||
std::is_pointer_v<Dp> && std::is_base_of_v<B, std::remove_pointer_t<Dp>>, int16_t>
|
||||
handle_get_value(Handle<B>& handle) {
|
||||
assert_invariant(handle);
|
||||
auto [p, tag] = handleToPointer(handle.getId());
|
||||
|
||||
if (isPoolHandle(handle.getId())) {
|
||||
// check for pool handle use-after-free
|
||||
if (UTILS_UNLIKELY(!mUseAfterFreeCheckDisabled)) {
|
||||
auto const pNode = static_cast<typename Allocator::Node*>(p);
|
||||
uint8_t age = pNode[-1].age;
|
||||
uint8_t test_value = pNode[-1].test_value;
|
||||
int16_t ret = (int16_t) ((age << 8) | test_value);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
// check for heap handle use-after-free
|
||||
if (UTILS_UNLIKELY(!mUseAfterFreeCheckDisabled)) {
|
||||
return -1;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
utils::CString getHandleTag(HandleBase::HandleId key) const noexcept;
|
||||
|
||||
template<typename B>
|
||||
@@ -276,7 +326,10 @@ private:
|
||||
class Allocator {
|
||||
friend class HandleAllocator;
|
||||
static constexpr size_t MIN_ALIGNMENT = alignof(std::max_align_t);
|
||||
struct Node { uint8_t age; };
|
||||
struct Node {
|
||||
uint8_t age;
|
||||
uint8_t test_value = 0xff;
|
||||
};
|
||||
// Note: using the `extra` parameter of PoolAllocator<>, even with a 1-byte structure,
|
||||
// generally increases all pool allocations by 8-bytes because of alignment restrictions.
|
||||
template<size_t SIZE>
|
||||
|
||||
@@ -643,6 +643,25 @@ void OpenGLDriver::createVertexBufferInfoR(
|
||||
AttributeArray attributes) {
|
||||
DEBUG_MARKER()
|
||||
construct<GLVertexBufferInfo>(vbih, bufferCount, attributeCount, attributes);
|
||||
|
||||
// test ----
|
||||
int16_t returned_value = handle_set_value<GLVertexBufferInfo*>(vbih, 90);
|
||||
uint8_t age = (uint8_t) (returned_value >> 8);
|
||||
uint8_t test_value = (returned_value & 0xff);
|
||||
switch (test_value) {
|
||||
case -2:
|
||||
case -1:
|
||||
case 0:
|
||||
utils::slog.w << "@@@ createVertexBufferInfoR: unexpected result, age:" << (int) age
|
||||
<< ", test_value:" << (int) test_value << utils::io::endl;
|
||||
break;
|
||||
default:
|
||||
FILAMENT_CHECK_POSTCONDITION(test_value == 1)
|
||||
<< "@@@ createVertexBufferInfoR: shouldn't happen, age:" << (int) age
|
||||
<< ", test_value:" << (int) test_value << utils::io::endl;
|
||||
break;
|
||||
}
|
||||
//----------
|
||||
}
|
||||
|
||||
void OpenGLDriver::createVertexBufferR(
|
||||
@@ -761,6 +780,25 @@ void OpenGLDriver::createProgramR(Handle<HwProgram> ph, Program&& program) {
|
||||
|
||||
construct<OpenGLProgram>(ph, *this, std::move(program));
|
||||
CHECK_GL_ERROR(utils::slog.e)
|
||||
|
||||
// test ----
|
||||
int16_t returned_value = handle_set_value<OpenGLProgram*>(ph, 100);
|
||||
uint8_t age = (uint8_t) (returned_value >> 8);
|
||||
uint8_t test_value = (returned_value & 0xff);
|
||||
switch (test_value) {
|
||||
case -2:
|
||||
case -1:
|
||||
case 0:
|
||||
utils::slog.w << "@@@ createProgramR: unexpected result, age:" << (int)age << ", test_value:" << (int)test_value
|
||||
<< utils::io::endl;
|
||||
break;
|
||||
default:
|
||||
FILAMENT_CHECK_POSTCONDITION(test_value == 1)
|
||||
<< "@@@ createProgramR: shouldn't happen, age:" << (int)age
|
||||
<< ", test_value:" << (int)test_value << utils::io::endl;
|
||||
break;
|
||||
}
|
||||
//----------
|
||||
}
|
||||
|
||||
UTILS_NOINLINE
|
||||
@@ -1918,6 +1956,25 @@ void OpenGLDriver::destroyRenderPrimitive(Handle<HwRenderPrimitive> rph) {
|
||||
void OpenGLDriver::destroyProgram(Handle<HwProgram> ph) {
|
||||
DEBUG_MARKER()
|
||||
if (ph) {
|
||||
// test ----
|
||||
int16_t returned_value = handle_set_value<OpenGLProgram*>(ph, 101);
|
||||
uint8_t age = (uint8_t) (returned_value >> 8);
|
||||
uint8_t test_value = (returned_value & 0xff);
|
||||
switch (test_value) {
|
||||
case -2:
|
||||
case -1:
|
||||
case 0:
|
||||
utils::slog.w << "@@@ destroyProgram: unexpected result, age:" << (int) age
|
||||
<< ", test_value:" << (int) test_value << utils::io::endl;
|
||||
break;
|
||||
default:
|
||||
FILAMENT_CHECK_POSTCONDITION(test_value == 1)
|
||||
<< "@@@ destroyProgram: shouldn't happen, age:" << (int) age
|
||||
<< ", test_value:" << (int) test_value << utils::io::endl;
|
||||
break;
|
||||
}
|
||||
//----------
|
||||
|
||||
OpenGLProgram* p = handle_cast<OpenGLProgram*>(ph);
|
||||
destruct(ph, p);
|
||||
}
|
||||
@@ -4066,6 +4123,24 @@ void OpenGLDriver::bindPipeline(PipelineState const& state) {
|
||||
setRasterState(state.rasterState);
|
||||
setStencilState(state.stencilState);
|
||||
gl.polygonOffset(state.polygonOffset.slope, state.polygonOffset.constant);
|
||||
// test ----
|
||||
Handle<HwProgram> pro = state.program;
|
||||
int16_t returned_value = handle_get_value<OpenGLProgram*>(pro);
|
||||
uint8_t age = (uint8_t)(returned_value >> 8);
|
||||
uint8_t test_value = (returned_value & 0xff);
|
||||
switch (test_value) {
|
||||
case -2:
|
||||
case -1:
|
||||
case 0:
|
||||
utils::slog.w << "@@@ bindPipeline: unexpected result, age:" << (int)age << ", test_value:" << (int)test_value << utils::io::endl;
|
||||
break;
|
||||
default:
|
||||
if (test_value != 100) {
|
||||
utils::slog.w << "@@@ bindPipeline: program is not valid OpenGLProgram, age:" << (int)age << ", test_value:" << (int)test_value << utils::io::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//----------
|
||||
OpenGLProgram* const p = handle_cast<OpenGLProgram*>(state.program);
|
||||
mValidProgram = useProgram(p);
|
||||
(*mCurrentPushConstants) = p->getPushConstants();
|
||||
|
||||
@@ -282,6 +282,20 @@ private:
|
||||
return mHandleAllocator.handle_cast<Dp, B>(handle);
|
||||
}
|
||||
|
||||
template<typename Dp, typename B>
|
||||
std::enable_if_t<std::is_pointer_v<Dp> && std::is_base_of_v<B, std::remove_pointer_t<Dp>>,
|
||||
int16_t>
|
||||
handle_set_value(Handle<B>& handle, uint8_t v) {
|
||||
return mHandleAllocator.handle_set_value<Dp, B>(handle, v);
|
||||
}
|
||||
|
||||
template<typename Dp, typename B>
|
||||
std::enable_if_t<std::is_pointer_v<Dp> && std::is_base_of_v<B, std::remove_pointer_t<Dp>>,
|
||||
int16_t>
|
||||
handle_get_value(Handle<B>& handle) {
|
||||
return mHandleAllocator.handle_get_value<Dp, B>(handle);
|
||||
}
|
||||
|
||||
friend class OpenGLProgram;
|
||||
friend class ShaderCompilerService;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user