mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 13:00:43 +00:00
Merge branch 'master' into newrenderer2
This commit is contained in:
commit
30c7dbd579
3 changed files with 27 additions and 15 deletions
|
@ -390,7 +390,7 @@ void VulkanFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
||||||
|
|
||||||
IHardwareTexture *VulkanFrameBuffer::CreateHardwareTexture(int numchannels)
|
IHardwareTexture *VulkanFrameBuffer::CreateHardwareTexture(int numchannels)
|
||||||
{
|
{
|
||||||
return new VkHardwareTexture();
|
return new VkHardwareTexture(numchannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
FMaterial* VulkanFrameBuffer::CreateMaterial(FGameTexture* tex, int scaleflags)
|
FMaterial* VulkanFrameBuffer::CreateMaterial(FGameTexture* tex, int scaleflags)
|
||||||
|
|
|
@ -37,8 +37,9 @@
|
||||||
|
|
||||||
VkHardwareTexture *VkHardwareTexture::First = nullptr;
|
VkHardwareTexture *VkHardwareTexture::First = nullptr;
|
||||||
|
|
||||||
VkHardwareTexture::VkHardwareTexture()
|
VkHardwareTexture::VkHardwareTexture(int numchannels)
|
||||||
{
|
{
|
||||||
|
mTexelsize = numchannels;
|
||||||
Next = First;
|
Next = First;
|
||||||
First = this;
|
First = this;
|
||||||
if (Next) Next->Prev = this;
|
if (Next) Next->Prev = this;
|
||||||
|
@ -126,7 +127,8 @@ void VkHardwareTexture::CreateImage(FTexture *tex, int translation, int flags)
|
||||||
if (!tex->isHardwareCanvas())
|
if (!tex->isHardwareCanvas())
|
||||||
{
|
{
|
||||||
FTextureBuffer texbuffer = tex->CreateTexBuffer(translation, flags | CTF_ProcessData);
|
FTextureBuffer texbuffer = tex->CreateTexBuffer(translation, flags | CTF_ProcessData);
|
||||||
CreateTexture(texbuffer.mWidth, texbuffer.mHeight, 4, VK_FORMAT_B8G8R8A8_UNORM, texbuffer.mBuffer);
|
bool indexed = flags & CTF_Indexed;
|
||||||
|
CreateTexture(texbuffer.mWidth, texbuffer.mHeight,indexed? 1 : 4, indexed? VK_FORMAT_R8_UNORM : VK_FORMAT_B8G8R8A8_UNORM, texbuffer.mBuffer, !indexed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -156,7 +158,7 @@ void VkHardwareTexture::CreateImage(FTexture *tex, int translation, int flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat format, const void *pixels)
|
void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat format, const void *pixels, bool mipmap)
|
||||||
{
|
{
|
||||||
if (w <= 0 || h <= 0)
|
if (w <= 0 || h <= 0)
|
||||||
throw CVulkanError("Trying to create zero size texture");
|
throw CVulkanError("Trying to create zero size texture");
|
||||||
|
@ -177,7 +179,7 @@ void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat form
|
||||||
|
|
||||||
ImageBuilder imgbuilder;
|
ImageBuilder imgbuilder;
|
||||||
imgbuilder.setFormat(format);
|
imgbuilder.setFormat(format);
|
||||||
imgbuilder.setSize(w, h, GetMipLevels(w, h));
|
imgbuilder.setSize(w, h, !mipmap ? 1 : GetMipLevels(w, h));
|
||||||
imgbuilder.setUsage(VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
|
imgbuilder.setUsage(VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
|
||||||
mImage.Image = imgbuilder.create(fb->device);
|
mImage.Image = imgbuilder.create(fb->device);
|
||||||
mImage.Image->SetDebugName("VkHardwareTexture.mImage");
|
mImage.Image->SetDebugName("VkHardwareTexture.mImage");
|
||||||
|
@ -203,7 +205,7 @@ void VkHardwareTexture::CreateTexture(int w, int h, int pixelsize, VkFormat form
|
||||||
|
|
||||||
fb->FrameDeleteList.Buffers.push_back(std::move(stagingBuffer));
|
fb->FrameDeleteList.Buffers.push_back(std::move(stagingBuffer));
|
||||||
|
|
||||||
mImage.GenerateMipmaps(cmdbuffer);
|
if (mipmap) mImage.GenerateMipmaps(cmdbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VkHardwareTexture::GetMipLevels(int w, int h)
|
int VkHardwareTexture::GetMipLevels(int w, int h)
|
||||||
|
@ -268,6 +270,7 @@ uint8_t *VkHardwareTexture::MapBuffer()
|
||||||
|
|
||||||
unsigned int VkHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, const char *name)
|
unsigned int VkHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, const char *name)
|
||||||
{
|
{
|
||||||
|
CreateTexture(w, h, mTexelsize, mTexelsize == 4 ? VK_FORMAT_B8G8R8A8_UNORM : VK_FORMAT_R8_UNORM, buffer, mipmap);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,10 +374,6 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state)
|
||||||
int clampmode = state.mClampMode;
|
int clampmode = state.mClampMode;
|
||||||
int translation = state.mTranslation;
|
int translation = state.mTranslation;
|
||||||
|
|
||||||
auto remap = translation <= 0 ? nullptr : GPalette.TranslationToTable(translation);
|
|
||||||
if (remap)
|
|
||||||
translation = remap->Index;
|
|
||||||
|
|
||||||
clampmode = base->GetClampMode(clampmode);
|
clampmode = base->GetClampMode(clampmode);
|
||||||
|
|
||||||
for (auto& set : mDescriptorSets)
|
for (auto& set : mDescriptorSets)
|
||||||
|
@ -395,11 +394,24 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state)
|
||||||
MaterialLayerInfo *layer;
|
MaterialLayerInfo *layer;
|
||||||
auto systex = static_cast<VkHardwareTexture*>(GetLayer(0, state.mTranslation, &layer));
|
auto systex = static_cast<VkHardwareTexture*>(GetLayer(0, state.mTranslation, &layer));
|
||||||
update.addCombinedImageSampler(descriptor.get(), 0, systex->GetImage(layer->layerTexture, state.mTranslation, layer->scaleFlags)->View.get(), sampler, systex->mImage.Layout);
|
update.addCombinedImageSampler(descriptor.get(), 0, systex->GetImage(layer->layerTexture, state.mTranslation, layer->scaleFlags)->View.get(), sampler, systex->mImage.Layout);
|
||||||
|
|
||||||
|
if (!(layer->scaleFlags & CTF_Indexed))
|
||||||
|
{
|
||||||
for (int i = 1; i < numLayers; i++)
|
for (int i = 1; i < numLayers; i++)
|
||||||
{
|
{
|
||||||
auto systex = static_cast<VkHardwareTexture*>(GetLayer(i, 0, &layer));
|
auto systex = static_cast<VkHardwareTexture*>(GetLayer(i, 0, &layer));
|
||||||
update.addCombinedImageSampler(descriptor.get(), i, systex->GetImage(layer->layerTexture, 0, layer->scaleFlags)->View.get(), sampler, systex->mImage.Layout);
|
update.addCombinedImageSampler(descriptor.get(), i, systex->GetImage(layer->layerTexture, 0, layer->scaleFlags)->View.get(), sampler, systex->mImage.Layout);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 1; i < 3; i++)
|
||||||
|
{
|
||||||
|
auto systex = static_cast<VkHardwareTexture*>(GetLayer(i, translation, &layer));
|
||||||
|
update.addCombinedImageSampler(descriptor.get(), i, systex->GetImage(layer->layerTexture, 0, layer->scaleFlags)->View.get(), sampler, systex->mImage.Layout);
|
||||||
|
}
|
||||||
|
numLayers = 3;
|
||||||
|
}
|
||||||
|
|
||||||
auto dummyImage = fb->GetRenderPassManager()->GetNullTextureView();
|
auto dummyImage = fb->GetRenderPassManager()->GetNullTextureView();
|
||||||
for (int i = numLayers; i < SHADER_MIN_REQUIRED_TEXTURE_LAYERS; i++)
|
for (int i = numLayers; i < SHADER_MIN_REQUIRED_TEXTURE_LAYERS; i++)
|
||||||
|
|
|
@ -24,7 +24,7 @@ class VkHardwareTexture : public IHardwareTexture
|
||||||
{
|
{
|
||||||
friend class VkMaterial;
|
friend class VkMaterial;
|
||||||
public:
|
public:
|
||||||
VkHardwareTexture();
|
VkHardwareTexture(int numchannels);
|
||||||
~VkHardwareTexture();
|
~VkHardwareTexture();
|
||||||
|
|
||||||
static void ResetAll();
|
static void ResetAll();
|
||||||
|
@ -45,7 +45,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void CreateImage(FTexture *tex, int translation, int flags);
|
void CreateImage(FTexture *tex, int translation, int flags);
|
||||||
|
|
||||||
void CreateTexture(int w, int h, int pixelsize, VkFormat format, const void *pixels);
|
void CreateTexture(int w, int h, int pixelsize, VkFormat format, const void *pixels, bool mipmap);
|
||||||
static int GetMipLevels(int w, int h);
|
static int GetMipLevels(int w, int h);
|
||||||
|
|
||||||
static VkHardwareTexture *First;
|
static VkHardwareTexture *First;
|
||||||
|
|
Loading…
Reference in a new issue