mirror of https://github.com/AxioDL/boo.git
early return case for setClampMode
This commit is contained in:
parent
b6d40fde97
commit
54676aff91
|
@ -73,6 +73,7 @@ enum class TextureFormat
|
||||||
/** Supported texture clamp modes */
|
/** Supported texture clamp modes */
|
||||||
enum class TextureClampMode
|
enum class TextureClampMode
|
||||||
{
|
{
|
||||||
|
Invalid = -1,
|
||||||
Repeat,
|
Repeat,
|
||||||
ClampToWhite,
|
ClampToWhite,
|
||||||
ClampToBlack,
|
ClampToBlack,
|
||||||
|
|
|
@ -295,6 +295,8 @@ static void SetClampMode(GLenum target, TextureClampMode clampMode)
|
||||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +304,7 @@ class GLTextureS : public GraphicsDataNode<ITextureS>
|
||||||
{
|
{
|
||||||
friend class GLDataFactory;
|
friend class GLDataFactory;
|
||||||
GLuint m_tex;
|
GLuint m_tex;
|
||||||
|
TextureClampMode m_clampMode = TextureClampMode::Invalid;
|
||||||
GLTextureS(const ObjToken<BaseGraphicsData>& parent, size_t width, size_t height, size_t mips,
|
GLTextureS(const ObjToken<BaseGraphicsData>& parent, size_t width, size_t height, size_t mips,
|
||||||
TextureFormat fmt, TextureClampMode clampMode, GLint aniso, const void* data, size_t sz)
|
TextureFormat fmt, TextureClampMode clampMode, GLint aniso, const void* data, size_t sz)
|
||||||
: GraphicsDataNode<ITextureS>(parent)
|
: GraphicsDataNode<ITextureS>(parent)
|
||||||
|
@ -383,6 +386,9 @@ public:
|
||||||
|
|
||||||
void setClampMode(TextureClampMode mode)
|
void setClampMode(TextureClampMode mode)
|
||||||
{
|
{
|
||||||
|
if (m_clampMode == mode)
|
||||||
|
return;
|
||||||
|
m_clampMode = mode;
|
||||||
glBindTexture(GL_TEXTURE_2D, m_tex);
|
glBindTexture(GL_TEXTURE_2D, m_tex);
|
||||||
SetClampMode(GL_TEXTURE_2D, mode);
|
SetClampMode(GL_TEXTURE_2D, mode);
|
||||||
}
|
}
|
||||||
|
@ -398,6 +404,7 @@ class GLTextureSA : public GraphicsDataNode<ITextureSA>
|
||||||
{
|
{
|
||||||
friend class GLDataFactory;
|
friend class GLDataFactory;
|
||||||
GLuint m_tex;
|
GLuint m_tex;
|
||||||
|
TextureClampMode m_clampMode = TextureClampMode::Invalid;
|
||||||
GLTextureSA(const ObjToken<BaseGraphicsData>& parent, size_t width, size_t height, size_t layers, size_t mips,
|
GLTextureSA(const ObjToken<BaseGraphicsData>& parent, size_t width, size_t height, size_t layers, size_t mips,
|
||||||
TextureFormat fmt, TextureClampMode clampMode, GLint aniso, const void* data, size_t sz)
|
TextureFormat fmt, TextureClampMode clampMode, GLint aniso, const void* data, size_t sz)
|
||||||
: GraphicsDataNode<ITextureSA>(parent)
|
: GraphicsDataNode<ITextureSA>(parent)
|
||||||
|
@ -458,6 +465,9 @@ public:
|
||||||
|
|
||||||
void setClampMode(TextureClampMode mode)
|
void setClampMode(TextureClampMode mode)
|
||||||
{
|
{
|
||||||
|
if (m_clampMode == mode)
|
||||||
|
return;
|
||||||
|
m_clampMode = mode;
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_tex);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, m_tex);
|
||||||
SetClampMode(GL_TEXTURE_2D_ARRAY, mode);
|
SetClampMode(GL_TEXTURE_2D_ARRAY, mode);
|
||||||
}
|
}
|
||||||
|
@ -480,6 +490,7 @@ class GLTextureD : public GraphicsDataNode<ITextureD>
|
||||||
size_t m_width = 0;
|
size_t m_width = 0;
|
||||||
size_t m_height = 0;
|
size_t m_height = 0;
|
||||||
int m_validMask = 0;
|
int m_validMask = 0;
|
||||||
|
TextureClampMode m_clampMode = TextureClampMode::Invalid;
|
||||||
GLTextureD(const ObjToken<BaseGraphicsData>& parent, size_t width, size_t height,
|
GLTextureD(const ObjToken<BaseGraphicsData>& parent, size_t width, size_t height,
|
||||||
TextureFormat fmt, TextureClampMode clampMode)
|
TextureFormat fmt, TextureClampMode clampMode)
|
||||||
: GraphicsDataNode<ITextureD>(parent), m_width(width), m_height(height)
|
: GraphicsDataNode<ITextureD>(parent), m_width(width), m_height(height)
|
||||||
|
@ -554,6 +565,9 @@ public:
|
||||||
|
|
||||||
void setClampMode(TextureClampMode mode)
|
void setClampMode(TextureClampMode mode)
|
||||||
{
|
{
|
||||||
|
if (m_clampMode == mode)
|
||||||
|
return;
|
||||||
|
m_clampMode = mode;
|
||||||
for (int i=0 ; i<3 ; ++i)
|
for (int i=0 ; i<3 ; ++i)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, m_texs[i]);
|
glBindTexture(GL_TEXTURE_2D, m_texs[i]);
|
||||||
|
|
|
@ -1476,13 +1476,20 @@ public:
|
||||||
m_cpuBuf.destroy(m_ctx);
|
m_cpuBuf.destroy(m_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setClampMode(TextureClampMode mode)
|
void _setClampMode(TextureClampMode mode)
|
||||||
{
|
{
|
||||||
m_clampMode = mode;
|
|
||||||
MakeSampler(m_ctx, m_sampler, mode, m_mips);
|
MakeSampler(m_ctx, m_sampler, mode, m_mips);
|
||||||
m_descInfo.sampler = m_sampler;
|
m_descInfo.sampler = m_sampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setClampMode(TextureClampMode mode)
|
||||||
|
{
|
||||||
|
if (m_clampMode == mode)
|
||||||
|
return;
|
||||||
|
m_clampMode = mode;
|
||||||
|
_setClampMode(mode);
|
||||||
|
}
|
||||||
|
|
||||||
void deleteUploadObjects()
|
void deleteUploadObjects()
|
||||||
{
|
{
|
||||||
m_cpuBuf.destroy(m_ctx);
|
m_cpuBuf.destroy(m_ctx);
|
||||||
|
@ -1506,7 +1513,7 @@ public:
|
||||||
texCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
texCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
m_gpuTex.create(m_ctx, &texCreateInfo);
|
m_gpuTex.create(m_ctx, &texCreateInfo);
|
||||||
|
|
||||||
setClampMode(m_clampMode);
|
_setClampMode(m_clampMode);
|
||||||
m_descInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
m_descInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
|
|
||||||
/* create image view */
|
/* create image view */
|
||||||
|
@ -1585,7 +1592,7 @@ class VulkanTextureSA : public GraphicsDataNode<ITextureSA>
|
||||||
TextureFormat m_fmt;
|
TextureFormat m_fmt;
|
||||||
size_t m_sz;
|
size_t m_sz;
|
||||||
size_t m_width, m_height, m_layers, m_mips;
|
size_t m_width, m_height, m_layers, m_mips;
|
||||||
TextureClampMode m_clampMode;
|
TextureClampMode m_clampMode = TextureClampMode::Invalid;
|
||||||
VkFormat m_vkFmt;
|
VkFormat m_vkFmt;
|
||||||
int m_pixelPitchNum = 1;
|
int m_pixelPitchNum = 1;
|
||||||
int m_pixelPitchDenom = 1;
|
int m_pixelPitchDenom = 1;
|
||||||
|
@ -1639,13 +1646,20 @@ public:
|
||||||
m_cpuBuf.destroy(m_ctx);
|
m_cpuBuf.destroy(m_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setClampMode(TextureClampMode mode)
|
void _setClampMode(TextureClampMode mode)
|
||||||
{
|
{
|
||||||
m_clampMode = mode;
|
|
||||||
MakeSampler(m_ctx, m_sampler, mode, m_mips);
|
MakeSampler(m_ctx, m_sampler, mode, m_mips);
|
||||||
m_descInfo.sampler = m_sampler;
|
m_descInfo.sampler = m_sampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setClampMode(TextureClampMode mode)
|
||||||
|
{
|
||||||
|
if (m_clampMode == mode)
|
||||||
|
return;
|
||||||
|
m_clampMode = mode;
|
||||||
|
_setClampMode(mode);
|
||||||
|
}
|
||||||
|
|
||||||
void deleteUploadObjects()
|
void deleteUploadObjects()
|
||||||
{
|
{
|
||||||
m_cpuBuf.destroy(m_ctx);
|
m_cpuBuf.destroy(m_ctx);
|
||||||
|
@ -1669,7 +1683,7 @@ public:
|
||||||
texCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
texCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
m_gpuTex.create(m_ctx, &texCreateInfo);
|
m_gpuTex.create(m_ctx, &texCreateInfo);
|
||||||
|
|
||||||
setClampMode(m_clampMode);
|
_setClampMode(m_clampMode);
|
||||||
m_descInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
m_descInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
|
|
||||||
/* create image view */
|
/* create image view */
|
||||||
|
@ -1791,6 +1805,7 @@ public:
|
||||||
VkDescriptorImageInfo m_descInfo[2];
|
VkDescriptorImageInfo m_descInfo[2];
|
||||||
~VulkanTextureD();
|
~VulkanTextureD();
|
||||||
|
|
||||||
|
void _setClampMode(TextureClampMode mode);
|
||||||
void setClampMode(TextureClampMode mode);
|
void setClampMode(TextureClampMode mode);
|
||||||
void load(const void* data, size_t sz);
|
void load(const void* data, size_t sz);
|
||||||
void* map(size_t sz);
|
void* map(size_t sz);
|
||||||
|
@ -1833,7 +1848,7 @@ public:
|
||||||
texCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
texCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
texCreateInfo.flags = 0;
|
texCreateInfo.flags = 0;
|
||||||
|
|
||||||
setClampMode(m_clampMode);
|
_setClampMode(m_clampMode);
|
||||||
for (int i=0 ; i<2 ; ++i)
|
for (int i=0 ; i<2 ; ++i)
|
||||||
{
|
{
|
||||||
/* create gpu image */
|
/* create gpu image */
|
||||||
|
@ -3550,13 +3565,19 @@ void VulkanTextureD::update(int b)
|
||||||
m_validSlots |= slot;
|
m_validSlots |= slot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void VulkanTextureD::setClampMode(TextureClampMode mode)
|
void VulkanTextureD::_setClampMode(TextureClampMode mode)
|
||||||
{
|
{
|
||||||
m_clampMode = mode;
|
|
||||||
MakeSampler(m_q->m_ctx, m_sampler, mode, 1);
|
MakeSampler(m_q->m_ctx, m_sampler, mode, 1);
|
||||||
for (int i=0 ; i<2 ; ++i)
|
for (int i=0 ; i<2 ; ++i)
|
||||||
m_descInfo[i].sampler = m_sampler;
|
m_descInfo[i].sampler = m_sampler;
|
||||||
}
|
}
|
||||||
|
void VulkanTextureD::setClampMode(TextureClampMode mode)
|
||||||
|
{
|
||||||
|
if (m_clampMode == mode)
|
||||||
|
return;
|
||||||
|
m_clampMode = mode;
|
||||||
|
_setClampMode(mode);
|
||||||
|
}
|
||||||
void VulkanTextureD::load(const void* data, size_t sz)
|
void VulkanTextureD::load(const void* data, size_t sz)
|
||||||
{
|
{
|
||||||
size_t bufSz = std::min(sz, m_cpuSz);
|
size_t bufSz = std::min(sz, m_cpuSz);
|
||||||
|
|
Loading…
Reference in New Issue