2020-05-31 08:53:11 +00:00
|
|
|
#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"
|
2022-07-02 08:09:59 +00:00
|
|
|
#include <list>
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
struct FMaterialState;
|
|
|
|
class VulkanDescriptorSet;
|
|
|
|
class VulkanImage;
|
|
|
|
class VulkanImageView;
|
|
|
|
class VulkanBuffer;
|
2022-07-02 08:09:59 +00:00
|
|
|
class VulkanFrameBuffer;
|
2020-05-31 08:53:11 +00:00
|
|
|
class FGameTexture;
|
|
|
|
|
|
|
|
class VkHardwareTexture : public IHardwareTexture
|
|
|
|
{
|
|
|
|
friend class VkMaterial;
|
|
|
|
public:
|
2022-07-02 08:09:59 +00:00
|
|
|
VkHardwareTexture(VulkanFrameBuffer* fb, int numchannels);
|
2020-05-31 08:53:11 +00:00
|
|
|
~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);
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
VulkanFrameBuffer* fb = nullptr;
|
|
|
|
std::list<VkHardwareTexture*>::iterator it;
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateImage(FTexture *tex, int translation, int flags);
|
|
|
|
|
2021-04-05 19:24:29 +00:00
|
|
|
void CreateTexture(int w, int h, int pixelsize, VkFormat format, const void *pixels, bool mipmap);
|
2020-05-31 08:53:11 +00:00
|
|
|
static int GetMipLevels(int w, int h);
|
|
|
|
|
|
|
|
VkTextureImage mImage;
|
|
|
|
int mTexelsize = 4;
|
|
|
|
|
|
|
|
VkTextureImage mDepthStencil;
|
|
|
|
|
|
|
|
uint8_t* mappedSWFB = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VkMaterial : public FMaterial
|
|
|
|
{
|
2022-07-02 08:09:59 +00:00
|
|
|
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;
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
private:
|
2020-05-31 08:53:11 +00:00
|
|
|
struct DescriptorEntry
|
|
|
|
{
|
|
|
|
int clampmode;
|
2022-06-06 09:45:02 +00:00
|
|
|
intptr_t remap;
|
2020-05-31 08:53:11 +00:00
|
|
|
std::unique_ptr<VulkanDescriptorSet> descriptor;
|
|
|
|
|
2022-06-06 09:45:02 +00:00
|
|
|
DescriptorEntry(int cm, intptr_t f, std::unique_ptr<VulkanDescriptorSet>&& d)
|
2020-05-31 08:53:11 +00:00
|
|
|
{
|
|
|
|
clampmode = cm;
|
2022-06-06 09:45:02 +00:00
|
|
|
remap = f;
|
2020-05-31 08:53:11 +00:00
|
|
|
descriptor = std::move(d);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<DescriptorEntry> mDescriptorSets;
|
2022-07-02 08:09:59 +00:00
|
|
|
};
|