Skip to content

Commit

Permalink
Implement mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
durswd committed Jan 10, 2024
1 parent 1cdb277 commit 8424f9a
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Dev/Cpp/3rdParty/LLGI
Submodule LLGI updated 61 files
+7 −4 CMakeLists.txt
+15 −4 scripts/transpile.py
+5 −1 src/CMakeLists.txt
+8 −4 src/DX12/LLGI.BufferDX12.cpp
+226 −109 src/DX12/LLGI.CommandListDX12.cpp
+4 −0 src/DX12/LLGI.CommandListDX12.h
+16 −3 src/DX12/LLGI.PipelineStateDX12.cpp
+152 −35 src/DX12/LLGI.TextureDX12.cpp
+11 −6 src/DX12/LLGI.TextureDX12.h
+9 −6 src/LLGI.Base.h
+1 −1 src/LLGI.Buffer.cpp
+3 −0 src/LLGI.CommandList.h
+2 −0 src/LLGI.Texture.cpp
+6 −0 src/LLGI.Texture.h
+12 −2 src/Metal/LLGI.CommandListMetal.h
+50 −3 src/Metal/LLGI.CommandListMetal.mm
+1 −1 src/Metal/LLGI.Metal_Impl.h
+2 −1 src/Metal/LLGI.TextureMetal.h
+38 −9 src/Metal/LLGI.TextureMetal.mm
+7 −1 src/Vulkan/LLGI.BaseVulkan.cpp
+26 −1 src/Vulkan/LLGI.BufferVulkan.cpp
+2 −0 src/Vulkan/LLGI.BufferVulkan.h
+178 −118 src/Vulkan/LLGI.CommandListVulkan.cpp
+23 −3 src/Vulkan/LLGI.CommandListVulkan.h
+16 −2 src/Vulkan/LLGI.PipelineStateVulkan.cpp
+2 −2 src/Vulkan/LLGI.PipelineStateVulkan.h
+11 −3 src/Vulkan/LLGI.PlatformVulkan.cpp
+97 −15 src/Vulkan/LLGI.TextureVulkan.cpp
+3 −1 src/Vulkan/LLGI.TextureVulkan.h
+1 −1 src_test/CMakeLists.txt
+21 −0 src_test/Shaders/GLSL_GL/readwrite_texture.comp
+21 −0 src_test/Shaders/GLSL_VULKAN/readwrite_texture.comp
+15 −0 src_test/Shaders/HLSL_DX12/readwrite_texture.comp
+22 −0 src_test/Shaders/Metal/readwrite_texture.comp
+ src_test/Shaders/SPIRV/basic.comp.spv
+ src_test/Shaders/SPIRV/instancing.vert.spv
+ src_test/Shaders/SPIRV/readwrite.comp.spv
+ src_test/Shaders/SPIRV/readwrite_texture.comp.spv
+ src_test/Shaders/SPIRV/simple_compute_rectangle.frag.spv
+ src_test/Shaders/SPIRV/simple_compute_rectangle.vert.spv
+ src_test/Shaders/SPIRV/simple_constant_rectangle.frag.spv
+ src_test/Shaders/SPIRV/simple_constant_rectangle.vert.spv
+ src_test/Shaders/SPIRV/simple_mrt_texture_rectangle.frag.spv
+ src_test/Shaders/SPIRV/simple_rectangle.frag.spv
+ src_test/Shaders/SPIRV/simple_rectangle.vert.spv
+ src_test/Shaders/SPIRV/simple_texture_rectangle.frag.spv
+ src_test/Shaders/SPIRV/simple_texture_rectangle.vert.spv
+ src_test/Shaders/SPIRV/textures.frag.spv
+ src_test/Shaders/SPIRV/vertex_structured.vert.spv
+ src_test/Shaders/SPIRV/vtf.vert.spv
+105 −6 src_test/test_compute_shader.cpp
+22 −22 src_test/test_simple_render.cpp
+1 −1 thirdparty/SPIRV-Cross
+1 −1 thirdparty/glslang
+1 −0 tools/CMakeLists.txt
+6 −0 tools/README.md
+3 −3 tools/ShaderTranspiler/CMakeLists.txt
+37 −4 tools/ShaderTranspiler/main.cpp
+5 −5 tools/ShaderTranspilerCore/CMakeLists.txt
+33 −7 tools/ShaderTranspilerCore/ShaderTranspilerCore.cpp
+5 −5 tools/ShaderTranspilerCore/ShaderTranspilerCore.h
1 change: 1 addition & 0 deletions Dev/Cpp/Effekseer/Effekseer/Effekseer.Base.Pre.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ enum class TextureWrapType : int32_t
{
Repeat = 0,
Clamp = 1,
Mirror = 2,
};

enum class CullingType : int32_t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ RenderState::RenderState(RendererImplemented* renderer, D3D11_COMPARISON_FUNC de
{
for (int32_t w = 0; w < TextureWrapCount; w++)
{
D3D11_TEXTURE_ADDRESS_MODE Addres[] = {
D3D11_TEXTURE_ADDRESS_MODE addresses[] = {
D3D11_TEXTURE_ADDRESS_WRAP,
D3D11_TEXTURE_ADDRESS_CLAMP,
D3D11_TEXTURE_ADDRESS_MIRROR,
};

D3D11_FILTER Filter[] = {
Expand All @@ -154,9 +155,9 @@ RenderState::RenderState(RendererImplemented* renderer, D3D11_COMPARISON_FUNC de

D3D11_SAMPLER_DESC SamlerDesc = {
Filter[f],
Addres[w],
Addres[w],
Addres[w],
addresses[w],
addresses[w],
addresses[w],
0.0f,
Anisotropic[f],
D3D11_COMPARISON_ALWAYS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RenderState : public ::EffekseerRenderer::RenderStateBase
static const int32_t CulTypeCount = 3;
static const int32_t AlphaTypeCount = 5;
static const int32_t TextureFilterCount = 2;
static const int32_t TextureWrapCount = 2;
static const int32_t TextureWrapCount = 3;

RendererImplemented* m_renderer;
ID3D11RasterizerState* m_rStates[CulTypeCount];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,29 +186,23 @@ void RenderState::Update(bool forced)

if (m_active.TextureWrapTypes[i] != m_next.TextureWrapTypes[i] || forced)
{
std::array<int32_t, 3> wraps = {
D3DTADDRESS_WRAP,
D3DTADDRESS_CLAMP,
D3DTADDRESS_MIRROR,
};

auto wrap = wraps[static_cast<int32_t>(m_next.TextureWrapTypes[i])];

// for VTF
if (i < 4)
{
m_renderer->GetDevice()->SetSamplerState(
i + D3DVERTEXTEXTURESAMPLER0,
D3DSAMP_ADDRESSU,
m_next.TextureWrapTypes[i] == ::Effekseer::TextureWrapType::Repeat ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP);

m_renderer->GetDevice()->SetSamplerState(
i + D3DVERTEXTEXTURESAMPLER0,
D3DSAMP_ADDRESSV,
m_next.TextureWrapTypes[i] == ::Effekseer::TextureWrapType::Repeat ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP);
m_renderer->GetDevice()->SetSamplerState(i + D3DVERTEXTEXTURESAMPLER0, D3DSAMP_ADDRESSU, wrap);
m_renderer->GetDevice()->SetSamplerState(i + D3DVERTEXTEXTURESAMPLER0, D3DSAMP_ADDRESSV, wrap);
}

m_renderer->GetDevice()->SetSamplerState(
i,
D3DSAMP_ADDRESSU,
m_next.TextureWrapTypes[i] == ::Effekseer::TextureWrapType::Repeat ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP);

m_renderer->GetDevice()->SetSamplerState(
i,
D3DSAMP_ADDRESSV,
m_next.TextureWrapTypes[i] == ::Effekseer::TextureWrapType::Repeat ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP);
m_renderer->GetDevice()->SetSamplerState(i, D3DSAMP_ADDRESSU, wrap);
m_renderer->GetDevice()->SetSamplerState(i, D3DSAMP_ADDRESSV, wrap);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ typedef char GLchar;
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
#define GL_TEXTURE0 0x84C0
#define GL_BLEND_SRC_ALPHA 0x80CB
#define GL_BLEND_DST_ALPHA 0x80CA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void RenderState::Update(bool forced)
static const GLint glfilterMin[] = {GL_NEAREST, GL_LINEAR_MIPMAP_LINEAR};
static const GLint glfilterMin_NoneMipmap[] = {GL_NEAREST, GL_LINEAR};
static const GLint glfilterMag[] = {GL_NEAREST, GL_LINEAR};
static const GLint glwrap[] = {GL_REPEAT, GL_CLAMP_TO_EDGE};
static const GLint glwrap[] = {GL_REPEAT, GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT};

if (m_renderer->GetDeviceType() == OpenGLDeviceType::OpenGL3 || m_renderer->GetDeviceType() == OpenGLDeviceType::OpenGLES3)
{
Expand Down Expand Up @@ -213,9 +213,9 @@ void RenderState::Update(bool forced)
{
GLExt::glActiveTexture(GL_TEXTURE0 + i);

int32_t wrap_ = (int32_t)m_next.TextureWrapTypes[i];
GLExt::glSamplerParameteri(m_samplers[i], GL_TEXTURE_WRAP_S, glwrap[wrap_]);
GLExt::glSamplerParameteri(m_samplers[i], GL_TEXTURE_WRAP_T, glwrap[wrap_]);
int32_t wrap = static_cast<int32_t>(m_next.TextureWrapTypes[i]);
GLExt::glSamplerParameteri(m_samplers[i], GL_TEXTURE_WRAP_S, glwrap[wrap]);
GLExt::glSamplerParameteri(m_samplers[i], GL_TEXTURE_WRAP_T, glwrap[wrap]);

GLExt::glBindSampler(i, m_samplers[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,10 @@ void RendererImplemented::SetPixelBufferToShader(const void* data, int32_t size,
void RendererImplemented::SetTextures(Shader* shader, Effekseer::Backend::TextureRef* textures, int32_t count)
{
auto state = GetRenderState()->GetActiveState();
LLGI::TextureWrapMode ws[2];
std::array<LLGI::TextureWrapMode, 3> ws;
ws[(int)Effekseer::TextureWrapType::Clamp] = LLGI::TextureWrapMode::Clamp;
ws[(int)Effekseer::TextureWrapType::Repeat] = LLGI::TextureWrapMode::Repeat;
ws[(int)Effekseer::TextureWrapType::Mirror] = LLGI::TextureWrapMode::Mirror;

LLGI::TextureMinMagFilter fs[2];
fs[(int)Effekseer::TextureFilterType::Linear] = LLGI::TextureMinMagFilter::Linear;
Expand Down
2 changes: 2 additions & 0 deletions Dev/Editor/EffekseerCore/Data/RendererCommonValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,8 @@ public enum WrapType : int
Repeat = 0,
[Key(key = "WrapType_Clamp")]
Clamp = 1,
[Key(key = "WrapType_Mirror")]
Mirror = 2,
}

public enum UVType : int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ FilterType_Nearest_Name,Nearest-Neighbor
FilterType_Linear_Name,Linear Interpolation
WrapType_Repeat_Name,Repeat
WrapType_Clamp_Name,Clamp
WrapType_Mirror_Name,Mirror
AlphaBlendType_Opacity_Name,Opacity
AlphaBlendType_Blend_Name,Blend
AlphaBlendType_Add_Name,Additive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ FilterType_Nearest_Name,Más cercano-próximo
FilterType_Linear_Name,Interpolación Lineal
WrapType_Repeat_Name,Repetir
WrapType_Clamp_Name,Pinza
WrapType_Mirror_Name,Mirror
AlphaBlendType_Opacity_Name,Opacidad
AlphaBlendType_Blend_Name,Blend
AlphaBlendType_Add_Name,Additivo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ FilterType_Nearest_Name,最近傍
FilterType_Linear_Name,線形
WrapType_Repeat_Name,繰り返し
WrapType_Clamp_Name,クランプ
WrapType_Mirror_Name,ミラー
AlphaBlendType_Opacity_Name,不透明
AlphaBlendType_Blend_Name,通常
AlphaBlendType_Add_Name,加算
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ FilterType_Nearest_Name,临近
FilterType_Linear_Name,线性插值
WrapType_Repeat_Name,重复
WrapType_Clamp_Name,裁剪
WrapType_Mirror_Name,Mirror
AlphaBlendType_Opacity_Name,不透明
AlphaBlendType_Blend_Name,混合
AlphaBlendType_Add_Name,加法
Expand Down

0 comments on commit 8424f9a

Please sign in to comment.