Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laszlo Agocs
qtrhi
Commits
0b886474
Commit
0b886474
authored
Mar 18, 2019
by
Laszlo Agocs
Browse files
gl: Add tex.compare func support
parent
bb04781d
Changes
2
Show whitespace changes
Inline
Side-by-side
src/rhi/qrhigles2.cpp
View file @
0b886474
...
...
@@ -200,6 +200,18 @@ QT_BEGIN_NAMESPACE
#define GL_MAX_DRAW_BUFFERS 0x8824
#endif
#ifndef GL_TEXTURE_COMPARE_MODE
#define GL_TEXTURE_COMPARE_MODE 0x884C
#endif
#ifndef GL_COMPARE_REF_TO_TEXTURE
#define GL_COMPARE_REF_TO_TEXTURE 0x884E
#endif
#ifndef GL_TEXTURE_COMPARE_FUNC
#define GL_TEXTURE_COMPARE_FUNC 0x884D
#endif
static
QSurfaceFormat
qrhigles2_effectiveFormat
()
{
QSurfaceFormat
fmt
=
QSurfaceFormat
::
defaultFormat
();
...
...
@@ -1330,6 +1342,31 @@ static inline GLenum toGlWrapMode(QRhiSampler::AddressMode m)
}
}
static
inline
GLenum
toGlTextureCompareFunc
(
QRhiSampler
::
CompareOp
op
)
{
switch
(
op
)
{
case
QRhiSampler
::
Never
:
return
GL_NEVER
;
case
QRhiSampler
::
Less
:
return
GL_LESS
;
case
QRhiSampler
::
Equal
:
return
GL_EQUAL
;
case
QRhiSampler
::
LessOrEqual
:
return
GL_LEQUAL
;
case
QRhiSampler
::
Greater
:
return
GL_GREATER
;
case
QRhiSampler
::
NotEqual
:
return
GL_NOTEQUAL
;
case
QRhiSampler
::
GreaterOrEqual
:
return
GL_GEQUAL
;
case
QRhiSampler
::
Always
:
return
GL_ALWAYS
;
default:
Q_UNREACHABLE
();
return
GL_NEVER
;
}
}
void
QRhiGles2
::
executeCommandBuffer
(
QRhiCommandBuffer
*
cb
)
{
QGles2CommandBuffer
*
cbD
=
QRHI_RES
(
QGles2CommandBuffer
,
cb
);
...
...
@@ -1762,6 +1799,12 @@ void QRhiGles2::setChangedUniforms(QRhiGraphicsPipeline *ps, QRhiShaderResourceB
f
->
glTexParameteri
(
texD
->
target
,
GL_TEXTURE_WRAP_S
,
samplerD
->
glwraps
);
f
->
glTexParameteri
(
texD
->
target
,
GL_TEXTURE_WRAP_T
,
samplerD
->
glwrapt
);
f
->
glTexParameteri
(
texD
->
target
,
GL_TEXTURE_WRAP_R
,
samplerD
->
glwrapr
);
if
(
samplerD
->
gltexcomparefunc
!=
GL_NEVER
)
{
f
->
glTexParameteri
(
texD
->
target
,
GL_TEXTURE_COMPARE_MODE
,
GL_COMPARE_REF_TO_TEXTURE
);
f
->
glTexParameteri
(
texD
->
target
,
GL_TEXTURE_COMPARE_FUNC
,
samplerD
->
gltexcomparefunc
);
}
else
{
f
->
glTexParameteri
(
texD
->
target
,
GL_TEXTURE_COMPARE_MODE
,
GL_NONE
);
}
}
f
->
glUniform1i
(
sampler
.
glslLocation
,
texUnit
);
...
...
@@ -2242,6 +2285,7 @@ bool QGles2Sampler::build()
glwraps
=
toGlWrapMode
(
m_addressU
);
glwrapt
=
toGlWrapMode
(
m_addressV
);
glwrapr
=
toGlWrapMode
(
m_addressW
);
gltexcomparefunc
=
toGlTextureCompareFunc
(
m_compareOp
);
generation
+=
1
;
return
true
;
...
...
src/rhi/qrhigles2_p.h
View file @
0b886474
...
...
@@ -113,6 +113,7 @@ struct QGles2Sampler : public QRhiSampler
GLenum
glwraps
;
GLenum
glwrapt
;
GLenum
glwrapr
;
GLenum
gltexcomparefunc
;
uint
generation
=
0
;
friend
class
QRhiGles2
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment