现在的位置: 首页 > 综合 > 正文

OpenGL 4.3 (Core Profile) – August 6, 2012 spec Fundamental 2.3 Command Execution

2018年05月27日 ⁄ 综合 ⁄ 共 5087字 ⁄ 字号 评论关闭

Most of the Specification discusses the behavior of a single context bound to a
single CPU thread. It is also possible for multiple contexts to share GL objects
and for each such context to be bound to a different thread. This section introduces
concepts related to GL command execution including error reporting, command
queue flushing, and synchronization between command streams. Using these tools
can increase performance and utilization of the GPU by separating loosely related

tasks into different contexts.

客户端多线程

The GL detects only a subset of those conditions that could be considered errors.
This is because in many cases error checking would adversely impact the performance
of an error-free program

error检查影响性能

The command enum GetError( void );
is used to obtain error information. Each detectable error is assigned a numeric
code. When an error is detected, a flag is set and the code is recorded. Further errors, if they occur, do not affect this recorded code. When GetError is called,
the code is returned and the flag is cleared, so that a further error will again record
its code. If a call to GetError returns NO_ERROR, then there has been no detectable
error since the last call to GetError (or since the GL was initialized).

调用一次GetError( void 先清除上次错误标志位,返回调用时刻最新的错误

To allow for distributed implementations, there may be several flag-code pairs.
In this case, after a call to GetError returns a value other than NO_ERROR each
subsequent call returns the non-zero code of a distinct flag-code pair (in unspecified
order), until all non-NO_ERROR codes have been returned. When there are no more
non-NO_ERROR error codes, all flags are reset. This scheme requires some positive
number of pairs of a flag bit and an integer. The initial state of all flags is cleared
and the initial value of all codes is NO_ERROR.

分布式错误码处理,没看明白

Table 2.3 summarizes GL errors. Currently, when an error flag is set, results
of GL operation are undefined only if an OUT_OF_MEMORY error has occurred. In
other cases, there are no side effects; the command which generates the error is
ignored so that it has no effect on GL state or framebuffer contents. Except as
otherwise noted, if the generating command returns a value, it returns zero. If
the generating command modifies values through a pointer argument, no change is
made to these values.

忽略错误原则

Error Description Offending command ignored?
INVALID_ENUM enum argument out of range Yes
INVALID_VALUE Numeric argument out of range Yes
INVALID_OPERATION Operation illegal in current state Yes
INVALID_FRAMEBUFFER_OPERATION Framebuffer object is not complete Yes
OUT_OF_MEMORY Not enough memory left to execute command Unknown
STACK_OVERFLOW Command would cause a stack overflow Yes
STACK_UNDERFLOW Command would cause a stack underflow Yes

If a command that requires an enumerated value is passed a symbolic constant
that is not one of those specified as allowable for that command, an
INVALID_ENUM error is generated. This is the case even if the argument is
a pointer to a symbolic constant, if the value or values pointed to are not
allowable for the given command.
If a negative number is provided where an argument of type sizei or
sizeiptr is specified, an INVALID_VALUE error is generated.
If memory is exhausted as a side effect of the execution of a command, an
OUT_OF_MEMORY error may be generated.

Otherwise, errors are generated only for conditions that are explicitly described
in the Specification.
When a command could potentially generate several different errors (for example,
when is passed separate enum and numeric parameters which are both out
of range), the GL implementation may choose to generate any of the applicable
errors.

几种可能错误产生原因

When an error is generated, the GL may also generate a debug output message
describing its cause (see chapter 20). The message has source DEBUG_SOURCE_-
API, type DEBUG_TYPE_ERROR, and an implementation-dependent ID.

Debug API可获得错误信息,第20章

In some cases, however, errors may be generated for a single command for
reasons not directly related to that command. One such example is that deferred
processing for shader programs may result in link errors detected only when attempting
to draw primitives using vertex specification commands. In such cases,
errors generated by a command may be described elsewhere in the specification
than the command itself.

错误有时也会延迟出现,造成不对应的情况,比如延迟处理shader

Coarse control over command queues is available using the command
void Flush( void );
which causes all previously issued GL commands to complete in finite time (although
such commands may still be executing when Flush returns).
The command
void Finish( void );
forces all previously issued GL commands to complete. Finish does not return
until all effects from such commands on GL client and server state and the framebuffer
are fully realized.

粗粒度下控制方法:Flush,调用即刻返回,(异步操作),Finish,完成命名才返回(同步操作)

Finer control over command execution can be expressed using fence commands
and sync objects, as discussed in section 4.1.

精细控制用 fence commands and sync objects(opengl3.2后才有的东西,opengles3.0也有)

The GL must perform a number of floating-point operations during the course of
its operation.
Implementations normally perform computations in floating-point, and must
meet the range and precision requirements defined under ”Floating-Point Computation”
below.
These requirements only apply to computations performed in GL operations
outside of shader execution, such as texture image specification and sampling, and
per-fragment operations. Range and precision requirements during shader execution
differ and are specified by the OpenGL Shading Language Specification .

浮点数操作规约和shader的浮点数操作各有不同

A 16-bit floating-point number has a 1-bit sign (S), a 5-bit exponent (E), and a
10-bit mantissa (M).

An unsigned 11-bit floating-point number has no sign bit, a 5-bit exponent (E),
and a 6-bit mantissa (M).

An unsigned 10-bit floating-point number has no sign bit, a 5-bit exponent (E),
and a 5-bit mantissa (M).

抱歉!评论已关闭.