mirror of
https://github.com/DrBeef/Raze.git
synced 2024-12-02 00:52:56 +00:00
91 lines
2 KiB
C++
91 lines
2 KiB
C++
#pragma once
|
|
|
|
#ifdef LoadImage
|
|
#undef LoadImage
|
|
#endif
|
|
|
|
#define SHADED_TEXTURE -1
|
|
#define DIRECT_PALETTE -2
|
|
|
|
#include "tarray.h"
|
|
#include "hw_ihwtexture.h"
|
|
#include "volk/volk.h"
|
|
#include "vk_imagetransition.h"
|
|
#include "hw_material.h"
|
|
#include <list>
|
|
|
|
struct FMaterialState;
|
|
class VulkanDescriptorSet;
|
|
class VulkanImage;
|
|
class VulkanImageView;
|
|
class VulkanBuffer;
|
|
class VulkanFrameBuffer;
|
|
class FGameTexture;
|
|
|
|
class VkHardwareTexture : public IHardwareTexture
|
|
{
|
|
friend class VkMaterial;
|
|
public:
|
|
VkHardwareTexture(VulkanFrameBuffer* fb, int numchannels);
|
|
~VkHardwareTexture();
|
|
|
|
void Reset();
|
|
|
|
// Software renderer stuff
|
|
void AllocateBuffer(int w, int h, int texelsize) override;
|
|
uint8_t *MapBuffer() override;
|
|
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, const char *name) override;
|
|
|
|
// Wipe screen
|
|
void CreateWipeTexture(int w, int h, const char *name);
|
|
|
|
VkTextureImage *GetImage(FTexture *tex, int translation, int flags);
|
|
VkTextureImage *GetDepthStencil(FTexture *tex);
|
|
|
|
VulkanFrameBuffer* fb = nullptr;
|
|
std::list<VkHardwareTexture*>::iterator it;
|
|
|
|
private:
|
|
void CreateImage(FTexture *tex, int translation, int flags);
|
|
|
|
void CreateTexture(int w, int h, int pixelsize, VkFormat format, const void *pixels, bool mipmap);
|
|
static int GetMipLevels(int w, int h);
|
|
|
|
VkTextureImage mImage;
|
|
int mTexelsize = 4;
|
|
|
|
VkTextureImage mDepthStencil;
|
|
|
|
uint8_t* mappedSWFB = nullptr;
|
|
};
|
|
|
|
class VkMaterial : public FMaterial
|
|
{
|
|
public:
|
|
VkMaterial(VulkanFrameBuffer* fb, FGameTexture* tex, int scaleflags);
|
|
~VkMaterial();
|
|
|
|
VulkanDescriptorSet* GetDescriptorSet(const FMaterialState& state);
|
|
|
|
void DeleteDescriptors() override;
|
|
|
|
VulkanFrameBuffer* fb = nullptr;
|
|
std::list<VkMaterial*>::iterator it;
|
|
|
|
private:
|
|
struct DescriptorEntry
|
|
{
|
|
int clampmode;
|
|
intptr_t remap;
|
|
std::unique_ptr<VulkanDescriptorSet> descriptor;
|
|
|
|
DescriptorEntry(int cm, intptr_t f, std::unique_ptr<VulkanDescriptorSet>&& d)
|
|
{
|
|
clampmode = cm;
|
|
remap = f;
|
|
descriptor = std::move(d);
|
|
}
|
|
};
|
|
|
|
std::vector<DescriptorEntry> mDescriptorSets;
|
|
};
|