~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/gallium/drivers/r300/r300_query.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    struct r300_screen *r300screen = r300->screen;
37
37
    struct r300_query *q;
38
38
 
39
 
    if (query_type != PIPE_QUERY_OCCLUSION_COUNTER) {
 
39
    if (query_type != PIPE_QUERY_OCCLUSION_COUNTER &&
 
40
        query_type != PIPE_QUERY_OCCLUSION_PREDICATE &&
 
41
        query_type != PIPE_QUERY_GPU_FINISHED) {
40
42
        return NULL;
41
43
    }
42
44
 
45
47
        return NULL;
46
48
 
47
49
    q->type = query_type;
48
 
    q->domain = RADEON_DOMAIN_GTT;
49
 
    q->buffer_size = 4096;
 
50
 
 
51
    if (query_type == PIPE_QUERY_GPU_FINISHED) {
 
52
        return (struct pipe_query*)q;
 
53
    }
50
54
 
51
55
    if (r300screen->caps.family == CHIP_FAMILY_RV530)
52
 
        q->num_pipes = r300screen->caps.num_z_pipes;
 
56
        q->num_pipes = r300screen->info.r300_num_z_pipes;
53
57
    else
54
 
        q->num_pipes = r300screen->caps.num_frag_pipes;
55
 
 
56
 
    insert_at_tail(&r300->query_list, q);
57
 
 
58
 
    /* Open up the occlusion query buffer. */
59
 
    q->buf = r300->rws->buffer_create(r300->rws, q->buffer_size, 4096,
60
 
                                         PIPE_BIND_CUSTOM, PIPE_USAGE_STREAM,
61
 
                                         q->domain);
 
58
        q->num_pipes = r300screen->info.r300_num_gb_pipes;
 
59
 
 
60
    q->buf = r300->rws->buffer_create(r300->rws, 4096, 4096,
 
61
                                      PIPE_BIND_CUSTOM, RADEON_DOMAIN_GTT);
 
62
    if (!q->buf) {
 
63
        FREE(q);
 
64
        return NULL;
 
65
    }
62
66
    q->cs_buf = r300->rws->buffer_get_cs_handle(q->buf);
63
67
 
64
68
    return (struct pipe_query*)q;
70
74
    struct r300_query* q = r300_query(query);
71
75
 
72
76
    pb_reference(&q->buf, NULL);
73
 
    remove_from_list(q);
74
77
    FREE(query);
75
78
}
76
79
 
87
90
    struct r300_context* r300 = r300_context(pipe);
88
91
    struct r300_query* q = r300_query(query);
89
92
 
 
93
    if (q->type == PIPE_QUERY_GPU_FINISHED)
 
94
        return;
 
95
 
90
96
    if (r300->query_current != NULL) {
91
97
        fprintf(stderr, "r300: begin_query: "
92
98
                "Some other query has already been started.\n");
110
116
    struct r300_context* r300 = r300_context(pipe);
111
117
    struct r300_query *q = r300_query(query);
112
118
 
 
119
    if (q->type == PIPE_QUERY_GPU_FINISHED) {
 
120
        pb_reference(&q->buf, NULL);
 
121
        r300_flush(pipe, RADEON_FLUSH_ASYNC,
 
122
                   (struct pipe_fence_handle**)&q->buf);
 
123
        return;
 
124
    }
 
125
 
113
126
    if (q != r300->query_current) {
114
127
        fprintf(stderr, "r300: end_query: Got invalid query.\n");
115
128
        assert(0);
129
142
    unsigned i;
130
143
    uint32_t temp, *map;
131
144
 
 
145
    if (q->type == PIPE_QUERY_GPU_FINISHED) {
 
146
        uint32_t *r = (uint32_t*)vresult;
 
147
 
 
148
        if (wait) {
 
149
            r300->rws->buffer_wait(q->buf, RADEON_USAGE_READWRITE);
 
150
            *r = TRUE;
 
151
        } else {
 
152
            *r = !r300->rws->buffer_is_busy(q->buf, RADEON_USAGE_READWRITE);
 
153
        }
 
154
        return *r;
 
155
    }
 
156
 
132
157
    map = r300->rws->buffer_map(q->buf, r300->cs,
133
158
                                PIPE_TRANSFER_READ |
134
159
                                (!wait ? PIPE_TRANSFER_DONTBLOCK : 0));
138
163
    /* Sum up the results. */
139
164
    temp = 0;
140
165
    for (i = 0; i < q->num_results; i++) {
141
 
        temp += *map;
 
166
        /* Convert little endian values written by GPU to CPU byte order */
 
167
        temp += util_le32_to_cpu(*map);
142
168
        map++;
143
169
    }
144
170
 
145
171
    r300->rws->buffer_unmap(q->buf);
146
172
 
 
173
    if (q->type == PIPE_QUERY_OCCLUSION_PREDICATE) {
 
174
        temp = temp != 0;
 
175
    }
147
176
    *((uint64_t*)vresult) = temp;
148
177
    return TRUE;
149
178
}
168
197
    }
169
198
}
170
199
 
171
 
void r300_init_query_functions(struct r300_context* r300) {
 
200
void r300_init_query_functions(struct r300_context* r300)
 
201
{
172
202
    r300->context.create_query = r300_create_query;
173
203
    r300->context.destroy_query = r300_destroy_query;
174
204
    r300->context.begin_query = r300_begin_query;