22 , maxWidth(maxWidth_), maxHeight(maxHeight_)
27 glUniform1i(p.getUniformLocation(
"edgeTex"), 2);
28 glUniform1i(p.getUniformLocation(
"offsetTex"), 3);
29 edgePosScaleUnif[i] = p.getUniformLocation(
"edgePosScale");
35 glTexImage2D(GL_TEXTURE_2D,
44#if OPENGL_VERSION >= OPENGL_3_3
45 GLint swizzleMask1[] = {GL_RED, GL_RED, GL_RED, GL_GREEN};
46 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask1);
48 edgeBuffer.
allocate(maxWidth * maxHeight);
51 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
52 std::string offsetName =
"shaders/HQ_xLiteOffsets.dat";
55 offsetName[10] = narrow<char>(
'0' + n);
56 File offsetFile(context.resolve(offsetName));
57 offsetTexture[i].bind();
58 glTexImage2D(GL_TEXTURE_2D,
66 offsetFile.
mmap().data());
67#if OPENGL_VERSION >= OPENGL_3_3
68 GLint swizzleMask2[] = {GL_RED, GL_RED, GL_RED, GL_GREEN};
69 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask2);
72 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
77 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
78 unsigned dstStartY,
unsigned dstEndY,
unsigned dstWidth,
79 unsigned logSrcHeight)
81 unsigned factorX = dstWidth / srcWidth;
83 if ((factorX >= 2) && ((srcWidth % 320) == 0)) {
84 setup(superImpose !=
nullptr);
86 glActiveTexture(GL_TEXTURE3);
87 offsetTexture[factorX - 2].bind();
88 glActiveTexture(GL_TEXTURE2);
90 glActiveTexture(GL_TEXTURE0);
92 int i = superImpose ? 1 : 0;
93 glUniform2f(edgePosScaleUnif[i], src.
getWidth() /
float(maxWidth), src.
getHeight() /
float(maxHeight));
96 srcStartY, srcEndY, srcWidth,
97 dstStartY, dstEndY, dstWidth,
102 srcStartY, srcEndY, srcWidth,
103 dstStartY, dstEndY, dstWidth,
108using Pixel = uint32_t;
110 unsigned srcStartY,
unsigned srcEndY,
unsigned lineWidth,
113 if ((lineWidth % 320) != 0)
return;
115 assert(maxWidth <= 1280);
117 auto tmpBuf2 =
subspan(tmpBufMax, 0, lineWidth / 2);
125 auto curr = paintFrame.
getLine(narrow<int>(srcStartY) - 1, buf1);
126 auto next = paintFrame.
getLine(narrow<int>(srcStartY) + 0, buf2);
130 auto mapped = edgeBuffer.
mapWrite();
131 auto numLines = srcEndY - srcStartY;
132 for (
auto yy :
xrange(numLines)) {
134 std::swap(buf1, buf2);
135 next = paintFrame.
getLine(narrow<int>(yy + srcStartY + 1), buf2);
137 auto dest = mapped.subspan(yy *
size_t(lineWidth), lineWidth);
138 assert(dest.size_bytes() == tmpBuf2.size_bytes());
139 memcpy(dest.data(), tmpBuf2.data(), tmpBuf2.size_bytes());
145 glTexSubImage2D(GL_TEXTURE_2D,
148 narrow<GLint>(srcStartY),
149 narrow<GLint>(lineWidth),
150 narrow<GLint>(numLines),
GLsizei getHeight() const
void allocate(GLuint size)
Allocate the maximum required size for this buffer.
void unmap() const
Unmaps the contents of this buffer.
void unbind() const
Unbind this buffer.
void bind() const
Bind this PixelBuffer.
std::span< 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, unsigned maxWidth, unsigned maxHeight)
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)
constexpr auto subspan(Range &&range, size_t offset, size_t count=std::dynamic_extent)
#define VLA_SSE_ALIGNED(TYPE, NAME, LENGTH)
constexpr auto xrange(T e)