计算机如何绘制屏幕?

发布于 2024-12-05 12:13:09 字数 1436 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如梦初醒的夏天 2024-12-12 12:13:09

基本上与从硬盘读取数据或播放声音效果的方式相同。

通过将某些数据写入特定的内存地址,这些地址由内存控制器映射到相关的外部硬件(在这些情况下为硬盘、GPU 或声卡)。当硬件接收到这些写入时,它将写入的数据解释为有关执行操作的指令。

CPU 确实与系统的其他部分隔离。它真正了解的只是内存总线。它可以在该总线上读取和写入数据,基本上就是这样。其中一些读/写会进入内存,而其他的则可以映射到各种硬件的控制寄存器,或者映射到设备的内存(如果存在),从而允许 CPU 与其他设备进行通信。

现代 GPU 有自己的专用 RAM,可以将数据加载到其中。因此,CPU 向 GPU 发送指令,指定在主内存中的何处可以找到用于生成屏幕内容的数据以及如何处理这些数据。然后,GPU 将该数据从主内存加载到自己的 RAM 中,在其中执行必要的转换和计算,然后将其写入显示器不断读取的帧缓冲区中。

Fundamentally the same way it reads from the harddrive, or plays a sound effect.

By writing certain data to specific memory addresses which are mapped by the memory controller to the external hardware in question (harddrive, GPU or sound card in these cases). When the hardware receives those writes, it interprets the data written as instructions about what to do.

The CPU is really kind of isolated from the rest of the system. All it really knows about is the memory bus. It can read and write data on that bus, and that's basically it. Some of these reads/writes go to memory, and others can be mapped to the control registers of various hardware, or to the device's memory if such exists, allowing the CPU to communicate with other devices.

A modern GPU has its own dedicated RAM, which it can load data into. So the CPU sends off instructions to the GPU, specifying where in main memory it can find the data used to generate the screen contents and what to do with it. Then the GPU loads that data from main memory into its own RAM, where it performs the necessary transformations and computations, before writing it into its frame buffer, which the monitor is constantly reading from.

猫瑾少女 2024-12-12 12:13:09

通常,视频卡中有一个名为帧缓冲区的内存区域。在那里写入一个值意味着建立像素的颜色值。

您可以将帧缓冲区视为 2D 数组,其中每个位代表屏幕上的一个像素。使用不同级别的缓冲区来表示颜色。如今,常见的帧缓冲区有 24 个级别(每个 RGB 颜色分量有 8 个级别),并允许定义 2^24 种可能的颜色。

如今,出于性能原因,通常通过 GPU 来访问帧缓冲区:即使 CPU 可以执行此任务,但其成本也相当昂贵。

Typically there is an area of memory called frame buffer in your video card. Writing a value there means to establish the color value of a pixel.

You can consider a frame buffer like a 2D array, where each bit represent a pixel on the screen. To represent colors are used different levels of buffer. Today a common frame buffer has 24 levels (8 for each RGB color component) and allows the definition of 2^24 possible colors.

Nowadays generally the access to the frame buffer occurs through the GPU for performance reasons: even if it is possible for the CPU to perform this task, it is quite expensive.

抚你发端 2024-12-12 12:13:09

某处有一个专用于视频屏幕的内存。屏幕上的每个像素都有一定的内存量。避免像调色板和黑白这样的历史解决方案,通常有一定数量的红色位,一些位用于蓝色,一些位用于绿色。添加这些颜色后,您可以获得包括白色在内的所有颜色(例如,我知道它们不是用于油漆的原色,不用担心它会起作用)。通常,您会发现 24 位颜色,因为它很容易管理 8 位、一个红色字节、一个绿色字节和一个蓝色字节,以及连接内存等。

视频硬件不断读取该内存并使用任何内容向显示器发送信号的技术,本质上告诉显示器特定像素点亮的红色、绿色和蓝色的数量,不断扫描屏幕以获取最新信息。

使用此内存的几种常见技术是使用称为双端口的技术,其中两个实体能够读取/写入内存。或者拥有两个记忆并交换它们。无论哪种情况,都有另一个实体,即处理器,要么是 CPU 本身,要么是现在视频卡/芯片中的许多小型图形处理器。在任何一种情况下,都会运行一些软件,这些软件会计算所有像素的位置和颜色,并将它们写入视频内存,具体取决于所使用的机制,内存的视频/显示器端会在有意义时进行更改。您不希望仅在屏幕上一次显示所输入字母的某些像素,然后在下一次显示其余部分,这可能会引起用户注意到的闪烁。

视频内存通常像系统内存一样映射,处理器可能会使用与访问非视频系统内存相同的指令。 GPU当然可以,但是CPU通常没有外设特定指令,uart、gpio、视频、USB、存储等。外设通常映射为cpu内存空间中的某些地址,并使用普通内存读/写指令。

由于算法的特殊类型,更重要的是视频游戏所需的计算量巨大,视频卡使用许多、许多、专用、简单的图形处理器,这些处理器可能在昨天、今天或明天具有视频内存特定指令出于性能、尺寸、功率或其他原因。可能不会改变的是帧缓冲存储器的模型,这种存储器保存了屏幕上的像素,视频硬件使用这些像素来创建发送到显示器的信号,以便它可以绘制屏幕。

There is a memory somewhere that is dedicated to the video screen. Each pixel on the screen has a certain amount of memory. Avoiding historical solutions like palettes and black and white, there is typically a certain number of bits for red, some bits for blue and some for green. When those colors are added you can get everything including white (I know they are not the primary colors used with paint for example, dont worry it works). Typically you will find 24 bit color because it is easy to manage 8 bits, a byte, of red, a byte of green and a byte of blue, and wire up memory, etc.

The video hardware is constantly reading this memory and using whatever technology to send signals to the monitor that essentially tell it the amount of red, green, and blue to light up for a particular pixel, constantly scanning the screen with up to date information.

A couple of common techniques for using this memory are to either use something called dual ported, where two entities are able to read/write the memory. Or to have two memories and swap them. In either case there is another entity, a processor, either the CPU itself, or these days many little graphics processors in the video card/chip. In either case some software runs and these compute the location and color of all the pixels and write them to video memory, depending on the mechanism used the video/monitor side of the memory takes the changes when it makes sense. you dont want to have only some of the pixels of the letters you are typing to show up on one pass across the screen then have the rest show up on the next pass, might get a flicker the user notices.

The video memory is typically mapped like system memory, the processor would likely use the same instructions it uses to access non-video, system, memory. Certainly the gpus might, but a cpu normally does not have peripheral specific instructions, uart, gpio, video, usb, storage, etc. The peripherals are usually mapped as certain addresses in the cpu's memory space and normal memory read/write instructions are used.

Because of the specialized types of algorithms, and more importantly the sheer number of computations needed for video games the video cards use many, many, specialized, simple, graphics processors, these might, yesterday, today, or tomorrow, have video memory specific instructions for performance or size or power or other reasons. What probably will not change is the model of having framebuffer memory, a memory that holds a screens worth of pixels that the video hardware uses to create the signals to send to the monitor so that it can draw the screen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文