Fix samples on null backend (add swapchain impl)
BUG= Change-Id: I96e6c58b4ec46af58f7c0a97c88308075efe68dd Reviewed-on: https://dawn-review.googlesource.com/c/3700 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
9dc1250d3e
commit
17be9deed6
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "dawn_native/null/NullBackend.h"
|
#include "dawn_native/null/NullBackend.h"
|
||||||
|
|
||||||
|
#include "common/SwapChainUtils.h"
|
||||||
#include "dawn_native/BackendConnection.h"
|
#include "dawn_native/BackendConnection.h"
|
||||||
#include "dawn_native/Commands.h"
|
#include "dawn_native/Commands.h"
|
||||||
#include "dawn_native/NullBackend.h"
|
#include "dawn_native/NullBackend.h"
|
||||||
|
@ -261,4 +262,35 @@ namespace dawn_native { namespace null {
|
||||||
void SwapChain::OnBeforePresent(TextureBase*) {
|
void SwapChain::OnBeforePresent(TextureBase*) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateNativeSwapChainImpl
|
||||||
|
|
||||||
|
class NativeSwapChainImpl {
|
||||||
|
public:
|
||||||
|
using WSIContext = struct {};
|
||||||
|
void Init(WSIContext* context) {
|
||||||
|
}
|
||||||
|
dawnSwapChainError Configure(dawnTextureFormat format,
|
||||||
|
dawnTextureUsageBit,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t height) {
|
||||||
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
|
}
|
||||||
|
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||||
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
|
}
|
||||||
|
dawnSwapChainError Present() {
|
||||||
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
|
}
|
||||||
|
dawn::TextureFormat GetPreferredFormat() const {
|
||||||
|
return dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl() {
|
||||||
|
dawnSwapChainImplementation impl;
|
||||||
|
impl = CreateSwapChainImplementation(new NativeSwapChainImpl());
|
||||||
|
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
||||||
|
return impl;
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace dawn_native::null
|
}} // namespace dawn_native::null
|
||||||
|
|
|
@ -16,10 +16,12 @@
|
||||||
#define DAWNNATIVE_NULLBACKEND_H_
|
#define DAWNNATIVE_NULLBACKEND_H_
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
|
#include <dawn/dawn_wsi.h>
|
||||||
#include <dawn_native/dawn_native_export.h>
|
#include <dawn_native/dawn_native_export.h>
|
||||||
|
|
||||||
namespace dawn_native { namespace null {
|
namespace dawn_native { namespace null {
|
||||||
DAWN_NATIVE_EXPORT dawnDevice CreateDevice();
|
DAWN_NATIVE_EXPORT dawnDevice CreateDevice();
|
||||||
|
DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl();
|
||||||
}} // namespace dawn_native::null
|
}} // namespace dawn_native::null
|
||||||
|
|
||||||
#endif // DAWNNATIVE_NULLBACKEND_H_
|
#endif // DAWNNATIVE_NULLBACKEND_H_
|
||||||
|
|
|
@ -26,11 +26,17 @@ namespace utils {
|
||||||
return dawn_native::null::CreateDevice();
|
return dawn_native::null::CreateDevice();
|
||||||
}
|
}
|
||||||
uint64_t GetSwapChainImplementation() override {
|
uint64_t GetSwapChainImplementation() override {
|
||||||
return 0;
|
if (mSwapchainImpl.userData == nullptr) {
|
||||||
|
mSwapchainImpl = dawn_native::null::CreateNativeSwapChainImpl();
|
||||||
|
}
|
||||||
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
return DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
return DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateNullBinding() {
|
BackendBinding* CreateNullBinding() {
|
||||||
|
|
Loading…
Reference in New Issue