Add Device::Tick for periodic work

This commit is contained in:
Corentin Wallez 2017-06-14 13:33:45 -04:00 committed by Corentin Wallez
parent b947993e1a
commit dbb5729e64
13 changed files with 32 additions and 3 deletions

View File

@ -205,6 +205,8 @@ namespace wire {
}
const uint8_t* HandleCommands(const uint8_t* commands, size_t size) override {
procs.deviceTick(knownDevice.Get(1)->handle);
while (size > sizeof(WireCmd)) {
WireCmd cmdId = *reinterpret_cast<const WireCmd*>(commands);

View File

@ -461,6 +461,9 @@
"name": "create texture builder",
"returns": "texture builder"
},
{
"name": "tick"
},
{
"name": "copy bind groups",
"args": [

View File

@ -130,6 +130,10 @@ namespace backend {
return new TextureBuilder(this);
}
void DeviceBase::Tick() {
TickImpl();
}
void DeviceBase::CopyBindGroups(uint32_t start, uint32_t count, BindGroupBase* source, BindGroupBase* target) {
// TODO(cwallez@chromium.org): update state tracking then call the backend
}

View File

@ -30,7 +30,6 @@ namespace backend {
~DeviceBase();
void HandleError(const char* message);
void SetErrorCallback(nxt::DeviceErrorCallback callback, nxt::CallbackUserdata userdata);
// Used by autogenerated code, returns itself
DeviceBase* GetDevice();
@ -52,6 +51,8 @@ namespace backend {
virtual TextureBase* CreateTexture(TextureBuilder* builder) = 0;
virtual TextureViewBase* CreateTextureView(TextureViewBuilder* builder) = 0;
virtual void TickImpl() = 0;
// Many NXT objects are completely immutable once created which means that if two
// builders are given the same arguments, they can return the same object. Reusing
// objects will help make comparisons between objects by a single pointer comparison.
@ -86,7 +87,9 @@ namespace backend {
ShaderModuleBuilder* CreateShaderModuleBuilder();
TextureBuilder* CreateTextureBuilder();
void Tick();
void CopyBindGroups(uint32_t start, uint32_t count, BindGroupBase* source, BindGroupBase* target);
void SetErrorCallback(nxt::DeviceErrorCallback callback, nxt::CallbackUserdata userdata);
private:
// The object caches aren't exposed in the header as they would require a lot of

View File

@ -99,7 +99,7 @@ namespace d3d12 {
this->renderTargetDescriptor = renderTargetDescriptor;
}
void Device::Tick() {
void Device::TickImpl() {
// Execute any pending commands
ASSERT_SUCCESS(pendingCommandList->Close());
ID3D12CommandList* commandLists[] = { pendingCommandList.Get() };

View File

@ -105,6 +105,8 @@ namespace d3d12 {
TextureBase* CreateTexture(TextureBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
void TickImpl() override;
ComPtr<ID3D12Device> GetD3D12Device();
ComPtr<ID3D12CommandQueue> GetCommandQueue();
ComPtr<ID3D12CommandAllocator> GetPendingCommandAllocator();
@ -114,7 +116,6 @@ namespace d3d12 {
void SetNextRenderTargetDescriptor(D3D12_CPU_DESCRIPTOR_HANDLE renderTargetDescriptor);
void Tick();
uint64_t GetSerial() const;
void IncrementSerial();

View File

@ -114,6 +114,8 @@ namespace metal {
TextureBase* CreateTexture(TextureBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
void TickImpl() override;
void SetNextDrawable(id<CAMetalDrawable> drawable);
void Present();

View File

@ -114,6 +114,9 @@ namespace metal {
return new TextureView(this, builder);
}
void Device::TickImpl() {
}
void Device::SetNextDrawable(id<CAMetalDrawable> drawable) {
[currentDrawable release];
currentDrawable = drawable;

View File

@ -89,6 +89,9 @@ namespace null {
return new TextureViewBase(builder);
}
void Device::TickImpl() {
}
void Device::AddPendingOperation(std::unique_ptr<PendingOperation> operation) {
pendingOperations.emplace_back(std::move(operation));
}

View File

@ -107,6 +107,8 @@ namespace null {
TextureBase* CreateTexture(TextureBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
void TickImpl() override;
void AddPendingOperation(std::unique_ptr<PendingOperation> operation);
std::vector<std::unique_ptr<PendingOperation>> AcquirePendingOperations();

View File

@ -97,6 +97,9 @@ namespace opengl {
return new TextureView(this, builder);
}
void Device::TickImpl() {
}
void Device::Reference() {
}

View File

@ -97,6 +97,8 @@ namespace opengl {
TextureBase* CreateTexture(TextureBuilder* builder) override;
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
void TickImpl() override;
// NXT API
void Reference();
void Release();

View File

@ -74,6 +74,7 @@ class WireTestsBase : public Test {
if (ignoreSetCallbackCalls) {
EXPECT_CALL(api, OnBuilderSetErrorCallback(_, _, _, _)).Times(AnyNumber());
}
EXPECT_CALL(api, DeviceTick(_)).Times(AnyNumber());
s2cBuf = new TerribleCommandBuffer();
c2sBuf = new TerribleCommandBuffer(wireServer);