21 glUniform1i(p.getUniformLocation(
"edgeTex"), 2);
22 glUniform1i(p.getUniformLocation(
"offsetTex"), 3);
23 glUniform1i(p.getUniformLocation(
"weightTex"), 4);
29 glTexImage2D(GL_TEXTURE_2D,
38 #if OPENGL_VERSION >= OPENGL_3_3
39 GLint swizzleMask[] = {GL_RED, GL_RED, GL_RED, GL_ONE};
40 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
45 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
46 string offsetsName =
"shaders/HQ_xOffsets.dat";
47 string weightsName =
"shaders/HQ_xWeights.dat";
50 offsetsName[10] = char(
'0') + n;
52 offsetTexture[i].
bind();
53 glTexImage2D(GL_TEXTURE_2D,
63 weightsName[10] = char(
'0') + n;
65 weightTexture[i].
bind();
66 glTexImage2D(GL_TEXTURE_2D,
76 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
81 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
82 unsigned dstStartY,
unsigned dstEndY,
unsigned dstWidth,
83 unsigned logSrcHeight)
85 unsigned factorX = dstWidth / srcWidth;
86 unsigned factorY = (dstEndY - dstStartY) / (srcEndY - srcStartY);
88 if ((srcWidth == 320) && (factorX > 1) && (factorX == factorY)) {
90 setup(superImpose !=
nullptr);
91 glActiveTexture(GL_TEXTURE4);
92 weightTexture[factorX - 2].
bind();
93 glActiveTexture(GL_TEXTURE3);
94 offsetTexture[factorX - 2].
bind();
95 glActiveTexture(GL_TEXTURE2);
97 glActiveTexture(GL_TEXTURE0);
99 srcStartY, srcEndY, srcWidth,
100 dstStartY, dstEndY, dstWidth,
104 srcStartY, srcEndY, srcWidth,
105 dstStartY, dstEndY, dstWidth,
110 using Pixel = uint32_t;
112 unsigned srcStartY,
unsigned srcEndY,
unsigned lineWidth,
115 if ((lineWidth != 320) || (srcEndY > 240))
return;
120 memset(tmpBuf2, 0,
sizeof(tmpBuf2));
125 const auto* curr = paintFrame.
getLinePtr(srcStartY - 1, lineWidth, buf1);
126 const auto* next = paintFrame.
getLinePtr(srcStartY + 0, lineWidth, buf2);
131 if (
auto* mapped = edgeBuffer.
mapWrite()) {
132 for (
auto y :
xrange(srcStartY, srcEndY)) {
134 std::swap(buf1, buf2);
135 next = paintFrame.
getLinePtr(y + 1, lineWidth, buf2);
137 memcpy(mapped + 320 * y, tmpBuf2, 320 *
sizeof(uint16_t));
143 glTexSubImage2D(GL_TEXTURE_2D,
GLsizei getHeight() const
void unmap() const
Unmaps the contents of this buffer.
void unbind() const
Unbind this buffer.
void setImage(GLuint width, GLuint height)
Sets the image for this buffer.
T * getOffset(GLuint x, GLuint y)
Gets a pointer relative to the start of this buffer.
void bind() const
Bind this PixelBuffer.
T * mapWrite()
Maps the contents of this buffer into memory.
void bind()
Makes this texture the active GL texture.
span< const uint8_t > mmap()
Map file in memory.
Interface for getting lines from a video frame.
const Pixel * getLinePtr(int line, unsigned width, Pixel *buf) const
Gets a pointer to the pixels of the given line number.
void uploadBlock(unsigned srcStartY, unsigned srcEndY, unsigned lineWidth, FrameSource &paintFrame) override
GLHQScaler(GLScaler &fallback)
void scaleImage(gl::ColorTexture &src, gl::ColorTexture *superImpose, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, unsigned dstStartY, unsigned dstEndY, unsigned dstWidth, unsigned logSrcHeight) override
Scales the image in the given area, which must consist of lines which are all equally wide.
Abstract base class for OpenGL scalers.
void setup(bool superImpose)
void execute(gl::ColorTexture &src, gl::ColorTexture *superImpose, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, unsigned dstStartY, unsigned dstEndY, unsigned dstWidth, unsigned logSrcHeight, bool textureFromZero=false)
Helper method to draw a rectangle with multiple texture coordinates.
virtual void scaleImage(gl::ColorTexture &src, gl::ColorTexture *superImpose, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, unsigned dstStartY, unsigned dstEndY, unsigned dstWidth, unsigned logSrcHeight)=0
Scales the image in the given area, which must consist of lines which are all equally wide.
gl::ShaderProgram program[2]
constexpr pointer data() const noexcept
std::unique_ptr< Context > context
void format(SectorAccessibleDisk &disk, bool dos1)
Format the given disk (= a single partition).
This file implemented 3 utility functions:
const FileContext & systemFileContext()
void calcEdgesGL(const uint32_t *curr, const uint32_t *next, Endian::L32 *edges2, EdgeOp edgeOp)
#define VLA_SSE_ALIGNED(TYPE, NAME, LENGTH)
constexpr auto xrange(T e)