diff options
author | Jerome Glisse <[email protected]> | 2010-09-17 10:41:50 -0400 |
---|---|---|
committer | Jerome Glisse <[email protected]> | 2010-09-17 10:49:05 -0400 |
commit | fd266ec62ca772a8551d2d7922d718d9d84bdf07 (patch) | |
tree | 1f664adfe2d523149885a4c19b0a240841053454 /src/gallium/winsys/r600/drm/r600.c | |
parent | d80bed15660e784a405c467be1ded8266d8ffc48 (diff) |
r600g: alternative command stream building from context
Winsys context build a list of register block a register block is
a set of consecutive register that will be emited together in the
same pm4 packet (the various r600_block* are there to provide basic
grouping that try to take advantage of states that are linked together)
Some consecutive register are emited each in a different block,
for instance the various cb[0-7]_base. At winsys context creation,
the list of block is created & an index into the list of block. So
to find into which block a register is in you simply use the register
offset and lookup the block index. Block are grouped together into
group which are the various pkt3 group of config, context, resource,
Pipe state build a list of register each state want to modify,
beside register value it also give a register mask so only subpart
of a register can be updated by a given pipe state (the oring is
in the winsys) There is no prebuild register list or define for
each pipe state. Once pipe state are built they are bound to
the winsys context.
Each of this functions will go through the list of register and
will find into which block each reg falls and will update the
value of the block with proper masking (vs/ps resource/constant
are specialized variant with somewhat limited capabilities).
Each block modified by r600_context_pipe_state_set* is marked as
dirty and we update a count of dwords needed to emit all dirty
state so far.
r600_context_pipe_state_set* should be call only when pipe context
change some of the state (thus when pipe bind state or set state)
Then to draw primitive you make a call to r600_context_draw
void r600_context_draw(struct r600_context *ctx, struct r600_draw *draw)
It will check if there is enough dwords in current cs buffer and
if not will flush. Once there is enough room it will copy packet
from dirty block and then add the draw packet3 to initiate the draw.
The flush will send the current cs, reset the count of dwords to
0 and remark all states that are enabled as dirty and recompute
the number of dwords needed to send the current context.
Signed-off-by: Jerome Glisse <[email protected]>
Diffstat (limited to 'src/gallium/winsys/r600/drm/r600.c')
-rw-r--r-- | src/gallium/winsys/r600/drm/r600.c | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/src/gallium/winsys/r600/drm/r600.c b/src/gallium/winsys/r600/drm/r600.c new file mode 100644 index 00000000000..af9b9187ab1 --- /dev/null +++ b/src/gallium/winsys/r600/drm/r600.c @@ -0,0 +1,129 @@ +/* + * Copyright 2010 Jerome Glisse <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Jerome Glisse + */ +#include "xf86drm.h" +#include "radeon_drm.h" +#include "r600_priv.h" + +enum radeon_family r600_get_family(struct radeon *r600) +{ + return r600->family; +} + +static int r600_get_device(struct radeon *r600) +{ + struct drm_radeon_info info; + + r600->device = 0; + info.request = RADEON_INFO_DEVICE_ID; + info.value = (uintptr_t)&r600->device; + return drmCommandWriteRead(r600->fd, DRM_RADEON_INFO, &info, sizeof(struct drm_radeon_info)); +} + +struct radeon *r600_new(int fd, unsigned device) +{ + struct radeon *r600; + int r; + + r600 = calloc(1, sizeof(*r600)); + if (r600 == NULL) { + return NULL; + } + r600->fd = fd; + r600->device = device; + if (fd >= 0) { + r = r600_get_device(r600); + if (r) { + R600_ERR("Failed to get device id\n"); + r600_delete(r600); + return NULL; + } + } + r600->family = radeon_family_from_device(r600->device); + if (r600->family == CHIP_UNKNOWN) { + R600_ERR("Unknown chipset 0x%04X\n", r600->device); + r600_delete(r600); + return NULL; + } + switch (r600->family) { + case CHIP_R600: + case CHIP_RV610: + case CHIP_RV630: + case CHIP_RV670: + case CHIP_RV620: + case CHIP_RV635: + case CHIP_RS780: + case CHIP_RS880: + case CHIP_RV770: + case CHIP_RV730: + case CHIP_RV710: + case CHIP_RV740: + break; + case CHIP_R100: + case CHIP_RV100: + case CHIP_RS100: + case CHIP_RV200: + case CHIP_RS200: + case CHIP_R200: + case CHIP_RV250: + case CHIP_RS300: + case CHIP_RV280: + case CHIP_R300: + case CHIP_R350: + case CHIP_RV350: + case CHIP_RV380: + case CHIP_R420: + case CHIP_R423: + case CHIP_RV410: + case CHIP_RS400: + case CHIP_RS480: + case CHIP_RS600: + case CHIP_RS690: + case CHIP_RS740: + case CHIP_RV515: + case CHIP_R520: + case CHIP_RV530: + case CHIP_RV560: + case CHIP_RV570: + case CHIP_R580: + case CHIP_CEDAR: + case CHIP_REDWOOD: + case CHIP_JUNIPER: + case CHIP_CYPRESS: + case CHIP_HEMLOCK: + default: + R600_ERR("unknown or unsupported chipset 0x%04X\n", r600->device); + break; + } + return r600; +} + +void r600_delete(struct radeon *r600) +{ + if (r600 == NULL) + return; + drmClose(r600->fd); + free(r600); +} |