25 glUniform1i(p.getUniformLocation(
"edgeTex"), 2);
26 glUniform1i(p.getUniformLocation(
"offsetTex"), 3);
32 glTexImage2D(GL_TEXTURE_2D,
41#if OPENGL_VERSION >= OPENGL_3_3
42 GLint swizzleMask1[] = {GL_RED, GL_RED, GL_RED, GL_GREEN};
43 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask1);
48 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
49 std::string offsetName =
"shaders/HQ_xLiteOffsets.dat";
52 offsetName[10] = narrow<char>(
'0' + n);
53 File offsetFile(context.resolve(offsetName));
54 offsetTexture[i].bind();
55 glTexImage2D(GL_TEXTURE_2D,
63 offsetFile.
mmap().data());
64#if OPENGL_VERSION >= OPENGL_3_3
65 GLint swizzleMask2[] = {GL_RED, GL_RED, GL_RED, GL_GREEN};
66 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask2);
69 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
74 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
75 unsigned dstStartY,
unsigned dstEndY,
unsigned dstWidth,
76 unsigned logSrcHeight)
78 unsigned factorX = dstWidth / srcWidth;
79 unsigned factorY = (dstEndY - dstStartY) / (srcEndY - srcStartY);
81 if ((srcWidth == 320) && (factorX > 1) && (factorX == factorY)) {
82 setup(superImpose !=
nullptr);
84 glActiveTexture(GL_TEXTURE3);
85 offsetTexture[factorX - 2].bind();
86 glActiveTexture(GL_TEXTURE2);
88 glActiveTexture(GL_TEXTURE0);
90 srcStartY, srcEndY, srcWidth,
91 dstStartY, dstEndY, dstWidth,
96 srcStartY, srcEndY, srcWidth,
97 dstStartY, dstEndY, dstWidth,
102using Pixel = uint32_t;
104 unsigned srcStartY,
unsigned srcEndY,
unsigned lineWidth,
107 if ((lineWidth != 320) || (srcEndY > 240))
return;
117 auto curr = paintFrame.
getLine(narrow<int>(srcStartY) - 1, buf1);
118 auto next = paintFrame.
getLine(narrow<int>(srcStartY) + 0, buf2);
122 if (
auto* mapped = edgeBuffer.
mapWrite()) {
123 for (
auto y :
xrange(srcStartY, srcEndY)) {
125 std::swap(buf1, buf2);
126 next = paintFrame.
getLine(narrow<int>(y + 1), buf2);
128 memcpy(mapped + 320 *
size_t(y), tmpBuf2.data(), 320 *
sizeof(uint16_t));
134 glTexSubImage2D(GL_TEXTURE_2D,
137 narrow<GLint>(srcStartY),
138 narrow<GLint>(lineWidth),
139 narrow<GLint>(srcEndY - srcStartY),
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() const
Makes this texture the active GL texture.
void setInterpolation(bool interpolation)
Enable/disable bilinear interpolation for this texture.
std::span< const uint8_t > mmap()
Map file in memory.
Interface for getting lines from a video frame.
std::span< const Pixel > getLine(int line, std::span< 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
GLHQLiteScaler(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)
Setup scaler.
std::array< gl::ShaderProgram, 2 > program
void execute(const gl::ColorTexture &src, const 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.
EndianT< uint32_t, ConvLittle< BIG > > L32
void format(SectorAccessibleDisk &disk, MSXBootSectorType bootType)
Format the given disk (= a single partition).
This file implemented 3 utility functions:
const FileContext & systemFileContext()
CharacterConverter::Pixel Pixel
void calcEdgesGL(std::span< const uint32_t > curr, std::span< const uint32_t > next, std::span< Endian::L32 > edges2, EdgeOp edgeOp)
constexpr void fill(ForwardRange &&range, const T &value)
#define VLA_SSE_ALIGNED(TYPE, NAME, LENGTH)
constexpr auto xrange(T e)