22 glUniform1i(p.getUniformLocation(
"edgeTex"), 2);
23 glUniform1i(p.getUniformLocation(
"offsetTex"), 3);
24 glUniform1i(p.getUniformLocation(
"weightTex"), 4);
30 glTexImage2D(GL_TEXTURE_2D,
39#if OPENGL_VERSION >= OPENGL_3_3
40 GLint swizzleMask[] = {GL_RED, GL_RED, GL_RED, GL_ONE};
41 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
46 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
47 std::string offsetsName =
"shaders/HQ_xOffsets.dat";
48 std::string weightsName =
"shaders/HQ_xWeights.dat";
51 offsetsName[10] = narrow<char>(
'0' + n);
53 offsetTexture[i].bind();
54 glTexImage2D(GL_TEXTURE_2D,
62 offsetsFile.
mmap().data());
64 weightsName[10] = narrow<char>(
'0' + n);
66 weightTexture[i].bind();
67 glTexImage2D(GL_TEXTURE_2D,
75 weightsFile.
mmap().data());
77 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
82 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
83 unsigned dstStartY,
unsigned dstEndY,
unsigned dstWidth,
84 unsigned logSrcHeight)
86 unsigned factorX = dstWidth / srcWidth;
87 unsigned factorY = (dstEndY - dstStartY) / (srcEndY - srcStartY);
89 if ((srcWidth == 320) && (factorX > 1) && (factorX == factorY)) {
91 setup(superImpose !=
nullptr);
92 glActiveTexture(GL_TEXTURE4);
93 weightTexture[factorX - 2].bind();
94 glActiveTexture(GL_TEXTURE3);
95 offsetTexture[factorX - 2].bind();
96 glActiveTexture(GL_TEXTURE2);
98 glActiveTexture(GL_TEXTURE0);
100 srcStartY, srcEndY, srcWidth,
101 dstStartY, dstEndY, dstWidth,
105 srcStartY, srcEndY, srcWidth,
106 dstStartY, dstEndY, dstWidth,
111using Pixel = uint32_t;
113 unsigned srcStartY,
unsigned srcEndY,
unsigned lineWidth,
116 if ((lineWidth != 320) || (srcEndY > 240))
return;
126 auto curr = paintFrame.
getLine(narrow<int>(srcStartY) - 1, buf1);
127 auto next = paintFrame.
getLine(narrow<int>(srcStartY) + 0, buf2);
132 if (
auto* mapped = edgeBuffer.
mapWrite()) {
133 for (
auto y :
xrange(srcStartY, srcEndY)) {
136 next = paintFrame.
getLine(narrow<int>(y + 1), buf2);
138 memcpy(mapped + 320 *
size_t(y), tmpBuf2.data(), 320 *
sizeof(uint16_t));
144 glTexSubImage2D(GL_TEXTURE_2D,
147 narrow<GLint>(srcStartY),
148 narrow<GLint>(lineWidth),
149 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()
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(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.
EndianT< uint32_t, ConvLittle< BIG > > L32
std::optional< Context > context
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)
void swap(openmsx::MemBuffer< T > &l, openmsx::MemBuffer< T > &r) noexcept
#define VLA_SSE_ALIGNED(TYPE, NAME, LENGTH)
constexpr auto xrange(T e)