mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
D3D12: Support caching DX shaders.
This change is a prerequisite to D3D pipeline caching. This change introduces: - Caching interface which enables the cache. - Helper for backends to load/store blobs to be cached. - Ability to cache HLSL shaders. Bug:dawn:549 Change-Id: I2af759882d18b3f45dc63e49dcb6a3caa1be3485 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32305 Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
cf89a68f46
commit
41b3f9c1e4
@@ -17,8 +17,11 @@
|
||||
|
||||
#include "dawn_platform/dawn_platform_export.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <dawn/webgpu.h>
|
||||
|
||||
namespace dawn_platform {
|
||||
|
||||
enum class TraceCategory {
|
||||
@@ -28,14 +31,43 @@ namespace dawn_platform {
|
||||
GPUWork, // Actual GPU work
|
||||
};
|
||||
|
||||
class DAWN_PLATFORM_EXPORT CachingInterface {
|
||||
public:
|
||||
CachingInterface();
|
||||
virtual ~CachingInterface();
|
||||
|
||||
// LoadData has two modes. The first mode is used to get a value which
|
||||
// corresponds to the |key|. The |valueOut| is a caller provided buffer
|
||||
// allocated to the size |valueSize| which is loaded with data of the
|
||||
// size returned. The second mode is used to query for the existence of
|
||||
// the |key| where |valueOut| is nullptr and |valueSize| must be 0.
|
||||
// The return size is non-zero if the |key| exists.
|
||||
virtual size_t LoadData(const WGPUDevice device,
|
||||
const void* key,
|
||||
size_t keySize,
|
||||
void* valueOut,
|
||||
size_t valueSize) = 0;
|
||||
|
||||
// StoreData puts a |value| in the cache which corresponds to the |key|.
|
||||
virtual void StoreData(const WGPUDevice device,
|
||||
const void* key,
|
||||
size_t keySize,
|
||||
const void* value,
|
||||
size_t valueSize) = 0;
|
||||
|
||||
private:
|
||||
CachingInterface(const CachingInterface&) = delete;
|
||||
CachingInterface& operator=(const CachingInterface&) = delete;
|
||||
};
|
||||
|
||||
class DAWN_PLATFORM_EXPORT Platform {
|
||||
public:
|
||||
Platform();
|
||||
virtual ~Platform();
|
||||
|
||||
virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category) = 0;
|
||||
virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category);
|
||||
|
||||
virtual double MonotonicallyIncreasingTime() = 0;
|
||||
virtual double MonotonicallyIncreasingTime();
|
||||
|
||||
virtual uint64_t AddTraceEvent(char phase,
|
||||
const unsigned char* categoryGroupEnabled,
|
||||
@@ -46,7 +78,13 @@ namespace dawn_platform {
|
||||
const char** argNames,
|
||||
const unsigned char* argTypes,
|
||||
const uint64_t* argValues,
|
||||
unsigned char flags) = 0;
|
||||
unsigned char flags);
|
||||
|
||||
// The |fingerprint| is provided by Dawn to inform the client to discard the Dawn caches
|
||||
// when the fingerprint changes. The returned CachingInterface is expected to outlive the
|
||||
// device which uses it to persistently cache objects.
|
||||
virtual CachingInterface* GetCachingInterface(const void* fingerprint,
|
||||
size_t fingerprintSize);
|
||||
|
||||
private:
|
||||
Platform(const Platform&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user