How to read Command Reference Instructions from Intel PRM

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
bigboyav
Posts: 10
Joined: Sat Dec 29, 2018 3:09 am

How to read Command Reference Instructions from Intel PRM

Post by bigboyav »

Hey all, I am trying to program the integrated graphics on my Intel Chip, which is of the Skylake series. If any of you have a skylake processor then I have saved you a good amount of time because I was not able to find a Programmer's Reference Manual on any official intel site. I found the below manual on 01.org after spending a good amount of time digging around google.

https://01.org/linuxgraphics/documentat ... e-platform

As you can see, there are about 21 seperate volumes, and my questions lies in intel-gfx-prm-osrc-skl-vol02a-commandreference-instructions.pdf. I'm not entirely sure what to do with the information given, but after more research I have 2 theories. For example I will use the 3DSTATE_WM_HZ_OP instruction [image 1]. So my first theory:

Given the information I assumed that Intel has given enough information for one to program the integrated graphics by directly writing the binary instruction (or to write an assembler). However after mroe digging around I found the following [image 2] on Intel's github (https://github.com/intel/external-mesa/ ... _defines.h) which led me to my second theory.

My second theory is a user would be able to use the given instruction by utilizing Intel's mesa library (I'm assuming its precompiled and the #define statement points to the address in memory were the function resides).

However I'm not entirely to sure, and after googling a variety of the instructions I figured I post on here, go to bed, and wake up to hopefully someone answering my question.

Thanks,
bigboyav
Attachments
3dstate_wm_hz_op_github.PNG
3dstate_wm_hz_op_github.PNG (1.89 KiB) Viewed 1518 times
3dstate_wm_hz_op_prm.PNG
User avatar
DropDemBits
Posts: 5
Joined: Thu Dec 29, 2016 2:06 am
Contact:

Re: How to read Command Reference Instructions from Intel PR

Post by DropDemBits »

Given the information I assumed that Intel has given enough information for one to program the integrated graphics by directly writing the binary instruction (or to write an assembler).
I assume that would be possible, although I have never attempted to write a graphics driver myself.
My second theory is a user would be able to use the given instruction by utilizing Intel's mesa library (I'm assuming its precompiled and the #define statement points to the address in memory were the function resides).
Mesa/Mesa3D is a graphics library providing an implementation of OpenGL, Vulkan, and other graphics apis, and provides an interface between the graphics apis and vendor specific drivers. The Mesa library provides an abstraction for interfacing with the GPU, so whatever Mesa can do, you can most likely do.

Now, on to specifics. 3DSTATE_WM_HZ_OP is a GPU command, and has a specific opcode. Mesa defines the opcode value inside _3DSTATE_WM_HZ_OP, and the value (0x7852) is just upper half of the 1st dword of the command. Here it is broken up:

Code: Select all

Binary Parts: 011 11 000 01010010
   Hex Parts:     7|   8|      52
Referencing the command reference, you can see those same values inside of the command table under "Programming Notes".

Code: Select all

Command Type:          011      (03h)
Command SubType:       11       (3h)
3D Command Opcode:     000      (0h)
3D Command Sub Opcode: 01010010 (52h)
The code where this define is used is inside of the brw_upload_initial_gpu_state function which sets up an initial state for the GPU. I don't know the specifics of what this function actually does, but that is what I gathered from a quick glance.

I suggest that you also look at the subsystems of the GPU in volume 3 of the PRM (here) to gain an understanding of each and better understand what each command is doing. However, you may do as you wish.
Developing K4
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: How to read Command Reference Instructions from Intel PR

Post by Korona »

In general Linux' model works as follows: Mesa implements a compiler that takes shaders (i.e. GLSL) as input and produces GPU-specific binary code (possibly via the intermediate languages TGSI and NIR). It might also generate GPU-specific binary code to implement other OpenGL commands. The kernel driver in the Linux kernel "just" performs memory management and uploads the commands to the GPU (see, for example, i915_gem_do_execbuffer). Mesa communicates with the kernel over ioctls on /dev/dri/card0. For an overview of those ioctls, you can take a look at the libdrm headers.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Post Reply