mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 10:51:35 +00:00
Assert HandleCommands succeeds
This commit is contained in:
parent
d5c1ecaf64
commit
21006bbe6f
@ -14,6 +14,7 @@
|
||||
|
||||
#include "SampleUtils.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/Platform.h"
|
||||
#include "utils/BackendBinding.h"
|
||||
#include "wire/TerribleCommandBuffer.h"
|
||||
@ -212,8 +213,8 @@ bool InitSample(int argc, const char** argv) {
|
||||
|
||||
void DoFlush() {
|
||||
if (cmdBufType == CmdBufType::Terrible) {
|
||||
c2sBuf->Flush();
|
||||
s2cBuf->Flush();
|
||||
ASSERT(c2sBuf->Flush());
|
||||
ASSERT(s2cBuf->Flush());
|
||||
}
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ namespace nxt { namespace wire {
|
||||
}
|
||||
|
||||
const char* HandleCommands(const char* commands, size_t size) override {
|
||||
while (size > sizeof(ReturnWireCmd)) {
|
||||
while (size >= sizeof(ReturnWireCmd)) {
|
||||
ReturnWireCmd cmdId = *reinterpret_cast<const ReturnWireCmd*>(commands);
|
||||
|
||||
bool success = false;
|
||||
|
@ -304,7 +304,7 @@ namespace nxt { namespace wire {
|
||||
const char* HandleCommands(const char* commands, size_t size) override {
|
||||
mProcs.deviceTick(mKnownDevice.Get(1)->handle);
|
||||
|
||||
while (size > sizeof(WireCmd)) {
|
||||
while (size >= sizeof(WireCmd)) {
|
||||
WireCmd cmdId = *reinterpret_cast<const WireCmd*>(commands);
|
||||
|
||||
bool success = false;
|
||||
|
@ -282,8 +282,8 @@ void NXTTest::SwapBuffersForCapture() {
|
||||
|
||||
void NXTTest::FlushWire() {
|
||||
if (gTestUsesWire) {
|
||||
mC2sBuf->Flush();
|
||||
mS2cBuf->Flush();
|
||||
ASSERT(mC2sBuf->Flush());
|
||||
ASSERT(mS2cBuf->Flush());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "mock/mock_nxt.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "wire/TerribleCommandBuffer.h"
|
||||
#include "wire/Wire.h"
|
||||
|
||||
@ -164,11 +165,11 @@ class WireTestsBase : public Test {
|
||||
}
|
||||
|
||||
void FlushClient() {
|
||||
mC2sBuf->Flush();
|
||||
ASSERT_TRUE(mC2sBuf->Flush());
|
||||
}
|
||||
|
||||
void FlushServer() {
|
||||
mS2cBuf->Flush();
|
||||
ASSERT_TRUE(mS2cBuf->Flush());
|
||||
}
|
||||
|
||||
MockProcTable api;
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include "wire/TerribleCommandBuffer.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace nxt { namespace wire {
|
||||
|
||||
TerribleCommandBuffer::TerribleCommandBuffer() {
|
||||
@ -39,16 +41,19 @@ namespace nxt { namespace wire {
|
||||
mOffset += size;
|
||||
|
||||
if (mOffset > sizeof(mBuffer)) {
|
||||
Flush();
|
||||
if (!Flush()) {
|
||||
return nullptr;
|
||||
}
|
||||
return GetCmdSpace(size);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void TerribleCommandBuffer::Flush() {
|
||||
mHandler->HandleCommands(mBuffer, mOffset);
|
||||
bool TerribleCommandBuffer::Flush() {
|
||||
bool success = mHandler->HandleCommands(mBuffer, mOffset) != nullptr;
|
||||
mOffset = 0;
|
||||
return success;
|
||||
}
|
||||
|
||||
}} // namespace nxt::wire
|
||||
|
@ -29,7 +29,7 @@ namespace nxt { namespace wire {
|
||||
void SetHandler(CommandHandler* handler);
|
||||
|
||||
void* GetCmdSpace(size_t size) override;
|
||||
void Flush() override;
|
||||
bool Flush() override;
|
||||
|
||||
private:
|
||||
CommandHandler* mHandler = nullptr;
|
||||
|
@ -25,7 +25,7 @@ namespace nxt { namespace wire {
|
||||
public:
|
||||
virtual ~CommandSerializer() = default;
|
||||
virtual void* GetCmdSpace(size_t size) = 0;
|
||||
virtual void Flush() = 0;
|
||||
virtual bool Flush() = 0;
|
||||
};
|
||||
|
||||
class CommandHandler {
|
||||
|
Loading…
x
Reference in New Issue
Block a user