25 glUniform1i(p.getUniformLocation(
"edgeTex"), 2);
26 glUniform1i(p.getUniformLocation(
"offsetTex"), 3);
27 glUniform1i(p.getUniformLocation(
"weightTex"), 4);
33 glTexImage2D(GL_TEXTURE_2D,
42#if OPENGL_VERSION >= OPENGL_3_3
43 GLint swizzleMask[] = {GL_RED, GL_RED, GL_RED, GL_ONE};
44 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
49 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
50 std::string offsetsName =
"shaders/HQ_xOffsets.dat";
51 std::string weightsName =
"shaders/HQ_xWeights.dat";
54 offsetsName[10] = narrow<char>(
'0' + n);
55 File offsetsFile(context.resolve(offsetsName));
56 offsetTexture[i].bind();
57 glTexImage2D(GL_TEXTURE_2D,
65 offsetsFile.
mmap().data());
67 weightsName[10] = narrow<char>(
'0' + n);
68 File weightsFile(context.resolve(weightsName));
69 weightTexture[i].bind();
70 glTexImage2D(GL_TEXTURE_2D,
78 weightsFile.
mmap().data());
80 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
85 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
86 unsigned dstStartY,
unsigned dstEndY,
unsigned dstWidth,
87 unsigned logSrcHeight)
89 unsigned factorX = dstWidth / srcWidth;
90 unsigned factorY = (dstEndY - dstStartY) / (srcEndY - srcStartY);
92 if ((srcWidth == 320) && (factorX > 1) && (factorX == factorY)) {
94 setup(superImpose !=
nullptr);
95 glActiveTexture(GL_TEXTURE4);
96 weightTexture[factorX - 2].bind();
97 glActiveTexture(GL_TEXTURE3);
98 offsetTexture[factorX - 2].bind();
99 glActiveTexture(GL_TEXTURE2);
101 glActiveTexture(GL_TEXTURE0);
103 srcStartY, srcEndY, srcWidth,
104 dstStartY, dstEndY, dstWidth,
108 srcStartY, srcEndY, srcWidth,
109 dstStartY, dstEndY, dstWidth,
114using Pixel = uint32_t;
116 unsigned srcStartY,
unsigned srcEndY,
unsigned lineWidth,
119 if ((lineWidth != 320) || (srcEndY > 240))
return;
129 auto curr = paintFrame.
getLine(narrow<int>(srcStartY) - 1, buf1);
130 auto next = paintFrame.
getLine(narrow<int>(srcStartY) + 0, buf2);
135 if (
auto* mapped = edgeBuffer.
mapWrite()) {
136 for (
auto y :
xrange(srcStartY, srcEndY)) {
138 std::swap(buf1, buf2);
139 next = paintFrame.
getLine(narrow<int>(y + 1), buf2);
141 memcpy(mapped + 320 *
size_t(y), tmpBuf2.data(), 320 *
sizeof(uint16_t));
147 glTexSubImage2D(GL_TEXTURE_2D,
150 narrow<GLint>(srcStartY),
151 narrow<GLint>(lineWidth),
152 narrow<GLint>(srcEndY - srcStartY),
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() const
Makes this texture the active GL 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
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)
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)